예제 #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MyGameStoreContext(serviceProvider.GetRequiredService <DbContextOptions <MyGameStoreContext> >()))
            {
                //look For Games
                if (context.Game.Any())
                {
                    return; // Db has been seeded
                }

                context.Game.AddRange(
                    new Game
                {
                    Title       = "World of warcraft",
                    ReleaseDate = DateTime.Parse("2003-1-11"),
                    Genre       = "MMO",
                    Publisher   = "Blizzard",
                    Price       = 60m,
                    Rating      = "18",
                    Description = "The adventures of azeroth bla bla bla...",
                    UnitsSold   = 1003400,
                });

                context.SaveChanges();
            }
        }
예제 #2
0
 public GameController(MyGameStoreContext context)
 {
     _context = context;
 }