private void PrepareDatabase() { var ct = CancellationToken.None; using (var connection = new SqlConnection(ConnectionString)) using (var context = new MigratorTestContext(connection)) { var manager = new SqlServerMigrationManager <MigratorTestContext>( context, new DefaultNamingNormalizer <MigratorTestContext>(), LoggingManager.LoggerFactory); manager.PrepareDatabaseAsync(ct) .ConfigureAwait(false) .GetAwaiter() .GetResult(); string migrationId; string className; MigrationsTestHelper.GenerateMigrationInfo( DateTimeOffset.UtcNow, out migrationId, out className); // Existing static migration manager.AddMigrationAsync(migrationId, className, null, ct) .ConfigureAwait(false) .GetAwaiter() .GetResult(); } }
public async Task GivenAnEmptyDatabaseWhenPreparingForMigrationsThenATableMustBeCreated() { var ct = CancellationToken.None; var manager = new SqlServerMigrationManager <SqlServerMigratorTestContext>( _fixture.Context, LoggingManager.LoggerFactory); await manager.PrepareDatabaseAsync(ct); var tableId = await _fixture.Context.RunAsync(async() => await _fixture.Context.QuerySingleAsync <long>(@" select count(*) as Total from ( select -- making sure all columns exist ContextName, MigrationId, ClassName, Description, AppliedOn from __DbMigratorHistory ) V", ct: ct), true, ct); Assert.Equal(0L, tableId); }
private void PrepareDatabase() { var ct = CancellationToken.None; using (var context = new SqlServerMigratorTestContext(Options)) { var manager = new SqlServerMigrationManager <SqlServerMigratorTestContext>(context, LoggingManager.LoggerFactory); manager.PrepareDatabaseAsync(ct) .ConfigureAwait(false) .GetAwaiter() .GetResult(); MigrationsTestHelper.GenerateMigrationInfo( DateTimeOffset.UtcNow, out var migrationId, out var className); // Existing static migration manager.AddMigrationAsync(migrationId, className, null, ct) .ConfigureAwait(false) .GetAwaiter() .GetResult(); } }