/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual async Task MigrateAsync( string targetMigration = null, CancellationToken cancellationToken = default(CancellationToken)) { var connection = _connection.DbConnection; _logger.LogDebug( RelationalEventId.MigrateUsingConnection, () => RelationalStrings.UsingConnection(connection.Database, connection.DataSource)); if (!await _historyRepository.ExistsAsync(cancellationToken)) { if (!await _databaseCreator.ExistsAsync(cancellationToken)) { await _databaseCreator.CreateAsync(cancellationToken); } var command = _rawSqlCommandBuilder.Build(_historyRepository.GetCreateScript()); await command.ExecuteNonQueryAsync(_connection, cancellationToken : cancellationToken); } var commandLists = GetMigrationCommandLists( await _historyRepository.GetAppliedMigrationsAsync(cancellationToken), targetMigration); foreach (var commandList in commandLists) { await _migrationCommandExecutor.ExecuteNonQueryAsync(commandList(), _connection, cancellationToken); } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual async Task MigrateAsync( string targetMigration = null, CancellationToken cancellationToken = default) { _logger.MigrateUsingConnection(this, _connection); if (!await _historyRepository.ExistsAsync(cancellationToken)) { if (!await _databaseCreator.ExistsAsync(cancellationToken)) { await _databaseCreator.CreateAsync(cancellationToken); } var command = _rawSqlCommandBuilder.Build(_historyRepository.GetCreateScript()); await command.ExecuteNonQueryAsync(_connection, cancellationToken : cancellationToken); } var commandLists = GetMigrationCommandLists( await _historyRepository.GetAppliedMigrationsAsync(cancellationToken), targetMigration); foreach (var commandList in commandLists) { await _migrationCommandExecutor.ExecuteNonQueryAsync(commandList(), _connection, cancellationToken); } }
public virtual async Task MigrateAsync( string targetMigration = null, CancellationToken cancellationToken = default(CancellationToken)) { var connection = _connection.DbConnection; _logger.LogDebug(RelationalStrings.UsingConnection(connection.Database, connection.DataSource)); if (!await _historyRepository.ExistsAsync(cancellationToken)) { if (!await _databaseCreator.ExistsAsync(cancellationToken)) { await _databaseCreator.CreateAsync(cancellationToken); } var command = _rawSqlCommandBuilder.Build(_historyRepository.GetCreateScript()); await ExecuteAsync( new[] { command }, cancellationToken); } var commands = GetMigrationCommands( await _historyRepository.GetAppliedMigrationsAsync(cancellationToken), targetMigration); foreach (var command in commands) { await ExecuteAsync(command(), cancellationToken); } }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual async Task MigrateAsync( string targetMigration = null, CancellationToken cancellationToken = default) { _logger.MigrateUsingConnection(this, _connection); if (!await _historyRepository.ExistsAsync(cancellationToken).ConfigureAwait(false)) { if (!await _databaseCreator.ExistsAsync(cancellationToken).ConfigureAwait(false)) { await _databaseCreator.CreateAsync(cancellationToken).ConfigureAwait(false); } var command = _rawSqlCommandBuilder.Build( _historyRepository.GetCreateScript()); await command.ExecuteNonQueryAsync( new RelationalCommandParameterObject( _connection, null, null, _currentContext.Context, _commandLogger), cancellationToken) .ConfigureAwait(false); } var commandLists = GetMigrationCommandLists( await _historyRepository.GetAppliedMigrationsAsync(cancellationToken).ConfigureAwait(false), targetMigration); foreach (var commandList in commandLists) { await _migrationCommandExecutor.ExecuteNonQueryAsync(commandList(), _connection, cancellationToken) .ConfigureAwait(false); } }
public virtual async Task <bool> ExistsAsync(CancellationToken cancellationToken = default(CancellationToken)) => await _databaseCreator.ExistsAsync(cancellationToken) && InterpretExistsResult( await _rawSqlCommandBuilder.Build(ExistsSql).ExecuteScalarAsync(_connection, cancellationToken: cancellationToken));
public virtual async Task <bool> ExistsAsync(CancellationToken cancellationToken = default(CancellationToken)) => await _databaseCreator.ExistsAsync(cancellationToken) && InterpretExistsResult(await _executor.ExecuteScalarAsync(_connection, ExistsSql, cancellationToken));