public static void EnsureDatabaseInitialized(IWebHost host) { using (IServiceScope serviceScope = host.Services.GetService <IServiceScopeFactory>().CreateScope()) { DatabaseInitializer.EnsureDatabaseInitialized(serviceScope); } }
public static void EnsureDatabaseInitialized(IHost host) { if (host == null) { throw new ArgumentNullException(nameof(host)); } using (var serviceScope = host.Services.GetService <IServiceScopeFactory>().CreateScope()) { ItEmployerDbContext context = serviceScope.ServiceProvider.GetRequiredService <ItEmployerDbContext>(); DatabaseInitializer.EnsureDatabaseInitialized(context); } }
public static async Task EnsureDatabaseInitialized(IWebHost host) { using (var serviceScope = host.Services.GetService <IServiceScopeFactory>().CreateScope()) { await DatabaseInitializer.EnsureDatabaseInitialized(serviceScope); } Task.Run(async() => { using (IServiceScope serviceScope = host.Services.GetService <IServiceScopeFactory>().CreateScope()) { await DatabaseInitializer.WarmUpContext(serviceScope); } }); }