Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5cbe408

Browse files
committed
Don't throw PendingModelChangesWarning when applying a specific migration
Fixes#35342
1 parent4b3e12f commit5cbe408

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

‎src/EFCore.Relational/Migrations/Internal/Migrator.cs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
usingSystem.Transactions;
55
usingMicrosoft.EntityFrameworkCore.Diagnostics.Internal;
6-
usingMicrosoft.EntityFrameworkCore.Metadata.Internal;
76

87
namespaceMicrosoft.EntityFrameworkCore.Migrations.Internal;
98

@@ -94,7 +93,7 @@ public Migrator(
9493
publicvirtualvoidMigrate(string?targetMigration)
9594
{
9695
varuseTransaction=_connection.CurrentTransactionisnull;
97-
ValidateMigrations(useTransaction);
96+
ValidateMigrations(useTransaction,targetMigration);
9897

9998
usingvartransactionScope=newTransactionScope(TransactionScopeOption.Suppress,TransactionScopeAsyncFlowOption.Enabled);
10099

@@ -219,7 +218,7 @@ public virtual async Task MigrateAsync(
219218
CancellationTokencancellationToken=default)
220219
{
221220
varuseTransaction=_connection.CurrentTransactionisnull;
222-
ValidateMigrations(useTransaction);
221+
ValidateMigrations(useTransaction,targetMigration);
223222

224223
usingvartransactionScope=newTransactionScope(TransactionScopeOption.Suppress,TransactionScopeAsyncFlowOption.Enabled);
225224

@@ -349,7 +348,7 @@ await _migrationCommandExecutor.ExecuteNonQueryAsync(
349348
}
350349
}
351350

352-
privatevoidValidateMigrations(booluseTransaction)
351+
privatevoidValidateMigrations(booluseTransaction,string?targetMigration)
353352
{
354353
if(!useTransaction
355354
&&_executionStrategy.RetriesOnFailure)
@@ -365,7 +364,8 @@ private void ValidateMigrations(bool useTransaction)
365364
{
366365
_logger.ModelSnapshotNotFound(this,_migrationsAssembly);
367366
}
368-
elseif(RelationalResources.LogPendingModelChanges(_logger).WarningBehavior!=WarningBehavior.Ignore
367+
elseif(targetMigration==null
368+
&&RelationalResources.LogPendingModelChanges(_logger).WarningBehavior!=WarningBehavior.Ignore
369369
&&HasPendingModelChanges())
370370
{
371371
varmodelSource=(ModelSource)_currentContext.Context.GetService<IModelSource>();

‎test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsInfrastructureSqlServerTest.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,7 @@ public async Task Empty_Migration_Creates_Database()
816816
{
817817
usingvarcontext=newBloggingContext(
818818
Fixture.TestStore.AddProviderOptions(
819-
newDbContextOptionsBuilder().EnableServiceProviderCaching(false))
820-
.ConfigureWarnings(e=>e.Log(RelationalEventId.PendingModelChangesWarning)).Options);
819+
newDbContextOptionsBuilder().EnableServiceProviderCaching(false)).Options);
821820

822821
context.Database.EnsureDeleted();
823822
GiveMeSomeTime(context);

‎test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerFixture.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
2626
b=>
2727
{
2828
b.OwnsOne(x=>x.OwnedReferenceRoot).ToJson("json_reference_custom_naming").HasColumnType("json");
29-
;
3029
b.OwnsMany(x=>x.OwnedCollectionRoot).HasColumnType("json").ToJson("json_collection_custom_naming");
3130
});
3231

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp