Exemplo n.º 1
0
 public async Task StartAsync(CancellationToken cancellationToken)
 {
     if (_hostingEnvironment.IsStaging() || _hostingEnvironment.IsProduction())
     {
         var migrationInitializer = new IdentityContextInitializerMigrate(_passwordHasher);
         await migrationInitializer.InitializeAsync(_context);
     }
     else if (_hostingEnvironment.IsIntegration())
     {
         var migrationInitializer = new IdentityContextInitializerDropMigrate(_passwordHasher);
         await migrationInitializer.InitializeAsync(_context);
     }
     else
     {
         var migrationInitializer = new IdentityContextInitializerDropCreate(_passwordHasher);
         await migrationInitializer.InitializeAsync(_context);
     }
 }
Exemplo n.º 2
0
        protected override async Task ExecuteAsync(IServiceProvider scopedServiceProvider, CancellationToken stoppingToken)
        {
            var context = scopedServiceProvider.GetRequiredService <IdentityContext>();

            if (_hostingEnvironment.IsStaging() || _hostingEnvironment.IsProduction())
            {
                var migrationInitializer = new IdentityContextInitializerMigrate();
                await migrationInitializer.InitializeAsync(context);
            }
            else if (_hostingEnvironment.IsIntegration())
            {
                //Can't have multi provider migrations so best to only use migrations in production.
                //var migrationInitializer = new IdentityContextInitializerDropMigrate();
                var migrationInitializer = new IdentityContextInitializerDropCreate();
                await migrationInitializer.InitializeAsync(context);
            }
            else
            {
                var migrationInitializer = new IdentityContextInitializerDropCreate();
                await migrationInitializer.InitializeAsync(context);
            }
        }