private static void InitializeDatabase(IHost host) { using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { DbInitializer.EnsurePopulated(services); IdentityInitializer.EnsurePopulated(services).Wait(); } catch (Exception e) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(e, "Databasen kunde inte fyllas."); } } }