public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var serviceProviders = scope.ServiceProvider; var context = serviceProviders.GetRequiredService <EventCatalogContext>(); EventCatalogSeed.Seed(context); } host.Run(); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build();//build the host using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; //Find all services (Startup,cs) var context = services.GetRequiredService <EventCatalogContext>(); //Check if catalogcontext service is running EventCatalogSeed.Seed(context); //If yes, then seed the database } host.Run(); //run the host }