Repository navigation
[release/11.0] Preserve owned replacements when original is requeried - #39663
Merged
Merged
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified, and the change includes targeted regression coverage for preserving replacement states and persisted values across the affected mappings.
No open issues 🎉
What changed in this PR
Preserves pending owned-entity replacements during tracking queries so replacements of deleted shared-identity entries remain Added and are persisted correctly by SaveChanges.
Changes:
- Skips Added-to-Unchanged normalization for replacements of deleted shared-identity entries.
- Adds SQLite regression coverage for table-splitting and JSON-owned mappings, including state and persisted-value assertions.
| File | Description |
|---|---|
| test/EFCore.Sqlite.FunctionalTests/Update/NonSharedModelUpdatesSqliteTest.cs | Adds regression tests verifying owned replacement states and persisted values for table-splitting and JSON mappings. |
| src/EFCore/Query/QueryContext.cs | Preserves Added entries that replace deleted shared-identity entries during tracking-query state normalization. |
Review effort: Lite
AndriySvyryd
marked this pull request as ready for review
November 15, 2026 20:52
Code coverage overviewLanguages: C# C# / code-coverage
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
artl93
approved these changes
Nov 16, 2026
artl93
left a comment
Member
There was a problem hiding this comment.
Regression, customer reported. M2 approved.
cincuranet
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39595
Description
A tracking query returning an owner can incorrectly mark a replacement owned reference as
Unchanged, discarding its pending update. Preserve the replacement'sAddedstate when it shares its identity with a deleted original.Customer impact
Changes to replaced owned references are silently lost when the owner is returned by a tracking query before
SaveChanges. A workaround is to save the replacement before executing another tracking query.How found
Customer reported on EF Core 11.0.0.
Regression
Yes, from EF Core 10.0.x, introduced by #38452
Testing
Added one parameterized regression test covering JSON and table splitting.
Risk
Low. The fix adds a single condition to the existing state transition, preserving ordinary Added-entry normalization.