protected override void Seed(book_store_for_developers.DAL.BooksContext context) { BooksInitializer.SeedBooksData(context); // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. }
public static void Main(string[] args) { // BuildWebHost(args).Run(); var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup <Startup>() .UseSetting("detailedErrors", "true") .Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetRequiredService <BookContext>(); BooksInitializer.Initialize(context); } host.Run(); }