public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()){ var services = scope.ServiceProvider; try{ Seeds.Initialize(services); } catch (Exception exception) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(exception, "The DB Could not be seeded"); } } host.Run(); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) try { var dbContxet = scope.ServiceProvider.GetService <WorkDbContext>(); Seeds.Initialize(dbContxet); } catch (Exception e) { var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >(); logger.LogError(e, "Database Migration Error!"); } host.Run(); }
public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetRequiredService <AirportContext>(); context.Database.Migrate(); Seeds.Initialize(services); host.Run(); } // BuildWebHost(args).Run(); }