diff --git a/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs b/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs index 2a4b086497f..2c22c50d651 100644 --- a/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs +++ b/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs @@ -17,6 +17,9 @@ public class CommandBatchPreparer : ICommandBatchPreparer private static readonly bool QuirkEnabled29647 = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue29647", out var enabled) && enabled; + private static readonly bool QuirkEnabled30601 + = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue30601", out var enabled) && enabled; + private readonly int _minBatchSize; private readonly bool _sensitiveLoggingEnabled; private readonly bool _detailedErrorsEnabled; @@ -983,6 +986,10 @@ private static bool IsModified(IReadOnlyList columns, IReadOnlyModifica } originalValue ??= entry.GetOriginalProviderValue(property); + if (!QuirkEnabled30601) + { + currentValue ??= entry.GetCurrentProviderValue(property); + } break; } diff --git a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs index b73a991abb8..1890f15045e 100644 --- a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs @@ -180,6 +180,44 @@ public virtual void Swap_filtered_unique_index_values() }); } + [ConditionalFact] + public virtual void Update_non_indexed_values() + { + var productId1 = new Guid("984ade3c-2f7b-4651-a351-642e92ab7146"); + var productId2 = new Guid("0edc9136-7eed-463b-9b97-bdb9648ab877"); + + ExecuteWithStrategyInTransaction( + context => + { + var product1 = context.Products.Find(productId1)!; + var product2 = context.Products.Find(productId2)!; + + product2.Price = product1.Price; + + context.SaveChanges(); + }, + context => + { + var product1 = new Product { Id = productId1, Name = "", Price = 1.49M }; + var product2 = new Product { Id = productId2, Name = "", Price = 1.49M }; + + context.Attach(product1).Property(p => p.DependentId).IsModified = true; + context.Attach(product2).Property(p => p.DependentId).IsModified = true; + + context.SaveChanges(); + }, + context => + { + var product1 = context.Products.Find(productId1)!; + var product2 = context.Products.Find(productId2)!; + + Assert.Equal(1.49M, product1.Price); + Assert.Null(product1.DependentId); + Assert.Equal(1.49M, product2.Price); + Assert.Null(product2.DependentId); + }); + } + [ConditionalFact] public abstract void Identifiers_are_generated_correctly();