// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory iLoggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); UserSeed.SeedAsync(app, iLoggerFactory).Wait(); }
public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <UserContext>(); context.Database.Migrate(); await UserSeed.SeedAsync(context); } catch (Exception exception) { Console.WriteLine(exception); throw; } } host.Run(); }