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();
                }
        }
Esempio n. 2
0
        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();
            }
        }