public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesGameContext (serviceProvider.GetRequiredService <DbContextOptions <RazorPagesGameContext> >())) { //Look for any games if (context.Game.Any()) { return; //DB has been seeded } context.Game.AddRange(new Game { Title = "Telltale's The Walking Dead Season 1", ReleaseDate = DateTime.Parse("2012-04-24"), Genre = "Point and click", NumberOfPlayableCharacters = 1, PlayableCharacterGender = "Male", PlayableCharacterRace = "Black" }, new Game { Title = "Life is Strange", ReleaseDate = DateTime.Parse("2015-01-30"), Genre = "Point and click", NumberOfPlayableCharacters = 1, PlayableCharacterGender = "Female", PlayableCharacterRace = "White" }, new Game { Title = "The Last of Us", ReleaseDate = DateTime.Parse("2013-06-14"), Genre = "Third person shooter", NumberOfPlayableCharacters = 2, PlayableCharacterGender = "Male, Female", PlayableCharacterRace = "White" }, new Game { Title = "Marvel's Spider-Man", ReleaseDate = DateTime.Parse("2018-09-07"), Genre = "Action-adventure", NumberOfPlayableCharacters = 3, PlayableCharacterGender = "Male, Female", PlayableCharacterRace = "White, Black" } ); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesGameContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesGameContext> >())) { // Look for any movies. if (context.Game.Any()) { return; // DB has been seeded } context.Game.AddRange( new Game { Title = "Uncharted", ReleaseDate = DateTime.Parse("2007-11-19"), Genre = "action-adventure", Price = 59.99M, Rating = "T" }, new Game { Title = "Uncharted 2", ReleaseDate = DateTime.Parse("2009-10-13"), Genre = "action-adventure", Price = 59.99M, Rating = "T" }, new Game { Title = "Uncharted 3", ReleaseDate = DateTime.Parse("2011-11-1"), Genre = "action-adventure", Price = 59.99M, Rating = "T" }, new Game { Title = "Uncharted 4", ReleaseDate = DateTime.Parse("2016-5-10"), Genre = "action-adventure", Price = 59.99M, Rating = "T" } ); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new RazorPagesGameContext( serviceProvider.GetRequiredService < DbContextOptions <RazorPagesGameContext> >())) { // Look for any movies. if (context.Game.Any()) { return; // DB has been seeded } context.Game.AddRange( new Game { Title = "Call of Duty", ReleaseDate = DateTime.Parse("2019-10-25"), Rating = "M", Price = 69.99M }, new Game { Title = "Gears of War", ReleaseDate = DateTime.Parse("2019-9-8"), Rating = "M", Price = 69.99M }, new Game { Title = "Borderlands 3", ReleaseDate = DateTime.Parse("2019-9-28"), Rating = "Comedy", Price = 69.99M }, new Game { Title = "Destiny 2", ReleaseDate = DateTime.Parse("2016-9-15"), Rating = "M", Price = 69.99M } ); context.SaveChanges(); } }