public static void Initialize(IntroDbContext context) { context.Database.EnsureCreated(); if (context.Movies.Any()) { return; // DB has been seeded } context.Movies.AddRange( new Movie { Title = "Avengers", Runtime = 2, Rating = 5, StoryLine = "A team of hearos save the earth!" }, new Movie { Title = "Captain Marvel", Runtime = 3, Rating = 5, StoryLine = "The boss of the Marvel heroes!" }); context.SaveChanges(); }
public static void Initialize(IntroDbContext context) { context.Database.EnsureCreated(); if (context.Movies.Any()) { return; // DB has been seeded } context.Movies.AddRange( new Movie { Title = "Avengers", Rating = 5, }, new Movie { Title = "Captain Marvel", Rating = 5, }); context.SaveChanges(); }