Пример #1
0
        public override async Task Run()
        {
            Logger.LogInformation("Initializing database migration context...");

            using (var migrationContext = await _migrationContextFactory.CreateMigrationContextAsync(_migrationTargetDatabase, _serviceProvider))
            {
                ExecuteDatabaseMigration(migrationContext.GetDbMigrator, migrationContext.SqlConnection);
            }
        }
Пример #2
0
        public override async Task Run()
        {
            Logger.LogInformation("Initializing database migration context...");

            IMigrationContext migrationContext = null;

            try
            {
                migrationContext = await _migrationContextFactory.CreateMigrationContextAsync(_migrationTargetDatabase, _serviceProvider);

                ExecuteDatabaseMigration(migrationContext.GetDbMigrator,
                                         migrationContext.SqlConnection,
                                         migrationContext.SqlConnectionAccessToken);
            }
            catch (Exception)
            {
                ExitCode = 1;
                throw;
            }
            finally
            {
                migrationContext?.SqlConnection?.Dispose();
            }
        }