public static void Initialize(IServiceProvider serviceProvider) { using (var context = new BoardGamesDBContext(serviceProvider.GetRequiredService <DbContextOptions <BoardGamesDBContext> >())) { // Look for any board games already in database. if (context.BoardGames.Any()) { return; // Database has been seeded } context.BoardGames.AddRange( new BoardGame { ID = 1, Title = "Candy Land", PublishingCompany = "Hasbro", MinPlayers = 2, MaxPlayers = 4 }, new BoardGame { ID = 2, Title = "Sorry!", PublishingCompany = "Hasbro", MinPlayers = 2, MaxPlayers = 4 }, new BoardGame { ID = 3, Title = "Ticket to Ride", PublishingCompany = "Days of Wonder", MinPlayers = 2, MaxPlayers = 5 }, new BoardGame { ID = 4, Title = "The Settlers of Catan (Expanded)", PublishingCompany = "Catan Studio", MinPlayers = 2, MaxPlayers = 6 }, new BoardGame { ID = 5, Title = "Carcasonne", PublishingCompany = "Z-Man Games", MinPlayers = 2, MaxPlayers = 5 }, new BoardGame { ID = 6, Title = "Sequence", PublishingCompany = "Jax Games", MinPlayers = 2, MaxPlayers = 6 }); context.SaveChanges(); } }
public IndexModel(BoardGamesDBContext context) { _context = context; }
public BoardGameRepository(BoardGamesDBContext context) : base(context) { }
public BoardGameController(BoardGamesDBContext context) { this.context = context; }
protected Repository(BoardGamesDBContext db) { Db = db; Dbset = db.Set <TEntity>(); }
public AddModel(BoardGamesDBContext context) { _context = context; }
public BoardGamesService(BoardGamesDBContext db) { _context = db; }