3
3
4
4
using System . Transactions ;
5
5
using Microsoft . EntityFrameworkCore . Diagnostics . Internal ;
6
- using Microsoft . EntityFrameworkCore . Metadata . Internal ;
7
6
8
7
namespace Microsoft . EntityFrameworkCore . Migrations . Internal ;
9
8
@@ -94,7 +93,7 @@ public Migrator(
94
93
public virtual void Migrate ( string ? targetMigration )
95
94
{
96
95
var useTransaction = _connection . CurrentTransaction is null ;
97
- ValidateMigrations ( useTransaction ) ;
96
+ ValidateMigrations ( useTransaction , targetMigration ) ;
98
97
99
98
using var transactionScope = new TransactionScope ( TransactionScopeOption . Suppress , TransactionScopeAsyncFlowOption . Enabled ) ;
100
99
@@ -219,7 +218,7 @@ public virtual async Task MigrateAsync(
219
218
CancellationToken cancellationToken = default )
220
219
{
221
220
var useTransaction = _connection . CurrentTransaction is null ;
222
- ValidateMigrations ( useTransaction ) ;
221
+ ValidateMigrations ( useTransaction , targetMigration ) ;
223
222
224
223
using var transactionScope = new TransactionScope ( TransactionScopeOption . Suppress , TransactionScopeAsyncFlowOption . Enabled ) ;
225
224
@@ -349,7 +348,7 @@ await _migrationCommandExecutor.ExecuteNonQueryAsync(
349
348
}
350
349
}
351
350
352
- private void ValidateMigrations ( bool useTransaction )
351
+ private void ValidateMigrations ( bool useTransaction , string ? targetMigration )
353
352
{
354
353
if ( ! useTransaction
355
354
&& _executionStrategy . RetriesOnFailure )
@@ -365,7 +364,8 @@ private void ValidateMigrations(bool useTransaction)
365
364
{
366
365
_logger . ModelSnapshotNotFound ( this , _migrationsAssembly ) ;
367
366
}
368
- else if ( RelationalResources . LogPendingModelChanges ( _logger ) . WarningBehavior != WarningBehavior . Ignore
367
+ else if ( targetMigration == null
368
+ && RelationalResources . LogPendingModelChanges ( _logger ) . WarningBehavior != WarningBehavior . Ignore
369
369
&& HasPendingModelChanges ( ) )
370
370
{
371
371
var modelSource = ( ModelSource ) _currentContext . Context . GetService < IModelSource > ( ) ;
0 commit comments