public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { PersonSeedData.Initialize(services); } catch (Exception ex) { throw; } } host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, PersonSeedData seeder) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseMvc(config => { config.MapRoute( name: "default", template: "{Controller}/{Action}/{Id?}", defaults: new { controller = "App", action = "Index" } ); }); seeder.EnsureSeedData().Wait(); }