Example #1
0
        public void EnsureCreated()
        {
            _context.Database.EnsureCreated();
            var albums = _galleryDataService.GetAlbumsAsync().Result;

            _context.Set <Album>().AddRange(albums);

            _context.Set <User>().AddRange(albums
                                           .Select(x => x.UserId)
                                           .Distinct()
                                           .Select(x => new User
            {
                Id = x
            }));

            var photos = _galleryDataService.GetPhotosAsync().Result;

            _context.Set <Photo>().AddRange(photos);
            _context.SaveChangesAsync();
        }
 public virtual IEnumerable <T> GetAll()
 => _context.Set <T>().AsEnumerable();