public static void Initialize(IServiceProvider serviceProvider) { using (var context = new WellnessShopContext( serviceProvider.GetRequiredService < DbContextOptions <WellnessShopContext> >())) { // Look for any movies. if (context.Store.Any()) { return; // DB has been seeded } context.Store.AddRange( new Store { Name = "Vitamin", Cost = 14.99M }, new Store { Name = "Supplement", Cost = 23.99M }, new Store { Name = "Supplement", Cost = 14.99M }, new Store { Name = "Vitamin", Cost = 7.99M } ); context.SaveChanges(); } }
public EFStoreRepository(WellnessShopContext ctx) { context = ctx; }