public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var env = services.GetRequiredService <IHostingEnvironment>(); if (env.IsDevelopment()) { var context = services.GetRequiredService <Db>(); context.Database.Migrate(); try { DbInitialiser.SeedTestData(context, services).Wait(); } catch (Exception) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogDebug("Seeding test data failed."); } } } host.Run(); }