From f28edd3855101fca4703c98f442c44a6e8681590 Mon Sep 17 00:00:00 2001 From: Andriy Svyryd Date: Tue, 12 Jan 2021 17:01:47 -0800 Subject: [PATCH] Add quirk mode for #23792 --- .../Migrations/Internal/MigrationsModelDiffer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs index 6410c946a1b..21ff4789482 100644 --- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs +++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs @@ -1898,6 +1898,7 @@ protected virtual Dictionary> DiffData( principalSourceTable = mainSourceEntityType.GetTableMappings().First().Table; } + var useOldBehavior = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue23792", out var enabled) && enabled; foreach (var sourceSeed in sourceEntityType.GetSeedData()) { var sourceEntry = GetEntry(sourceSeed, sourceEntityType, _sourceUpdateAdapter); @@ -1985,7 +1986,7 @@ protected virtual Dictionary> DiffData( { if (targetProperty.GetAfterSaveBehavior() != PropertySaveBehavior.Save && (targetProperty.ValueGenerated & ValueGenerated.OnUpdate) == 0 - && (targetKeyMap.Count == 1 || entry.EntityType.Name == sourceEntityType.Name)) + && (useOldBehavior || targetKeyMap.Count == 1 || entry.EntityType.Name == sourceEntityType.Name)) { entryMapping.RecreateRow = true; break;