public static void EnsureDatabaseInitialized(IWebHost host)
 {
     using (IServiceScope serviceScope = host.Services.GetService <IServiceScopeFactory>().CreateScope())
     {
         DatabaseInitializer.EnsureDatabaseInitialized(serviceScope);
     }
 }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        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);
                }
            });
        }