Exemplo n.º 1
0
        public override void MigrateDatabaseAndSeed(string connectionString)
        {
            using (var context = TestHelper.GetContext <ApplicationContext>(connectionString, false))
            {
                var migration = new ApplicationContextInitializerMigrate(context);
                migration.Initialize();
            }

            using (var context = TestHelper.GetContext <IdentityContext>(connectionString, false))
            {
                var migration = new IdentityContextInitializerMigrate(context);
                migration.Initialize();
            }
        }
 public void Execute()
 {
     using (var dbContext = _dbContextFactory.GetFactory <IdentityContext>().CreateDbContext())
     {
         if (_hostingEnvironment.IsDevelopment())
         {
             var migrationInitializer = new IdentityContextInitializerDropCreate(dbContext);
             migrationInitializer.Initialize();
         }
         else
         {
             var migrationInitializer = new IdentityContextInitializerMigrate(dbContext);
             migrationInitializer.Initialize();
         }
     }
 }
Exemplo n.º 3
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.º 4
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);
            }
        }