Esempio n. 1
0
 public LogsRepository(BoardGamesDbContext dbContext) : base(dbContext)
 {
 }
        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();
            }
        }
Esempio n. 3
0
 public AddModel(BoardGamesDbContext context)
 {
     _context = context;
 }