[release/11.0] Allow unconstrained relationships to break SaveChanges command cycles - #38989
Open
AndriySvyryd with Copilot wants to merge 3 commits into
Open
AndriySvyryd with Copilot wants to merge 3 commits into
AndriySvyryd with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix false circular dependency during SaveChanges with IsConstrained(false)
Allow unconstrained relationships to break SaveChanges command cycles
Sep 14, 2026
Member
|
@copilot Update progress by rewriting the PR summary using this template: |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The generated-key boundary guard lacks direct regression coverage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Allows unconstrained foreign-key dependencies to break SaveChanges command cycles while preserving generated-key batching boundaries.
Changes:
- Marks eligible unconstrained FK graph edges as breakable.
- Adds regression coverage for cyclic insert ordering.
File summaries
| File | Description |
|---|---|
CommandBatchPreparer.cs |
Updates dependency-edge breakability. |
CommandBatchPreparerTest.cs |
Tests unconstrained cycle resolution. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
Contributor
Author
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
AndriySvyryd
marked this pull request as ready for review
September 14, 2026 20:50
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 #38978
Description
Relationships configured with
IsConstrained(false)were treated as mandatorySaveChangescommand dependencies, causing false circular-dependency errors despite having no database constraint. The change makes an unconstrained foreign-key edge breakable only when it does not require a store-generated-value batching boundary.Customer impact
Affected applications cannot persist otherwise valid graphs containing an unconstrained reverse relationship in one
SaveChangescall; EF Core throws a circular-dependency exception. A workaround is to persist the entities in separate operations or avoid the cyclic relationship configuration.How found
Customer reported in #38978. The number of affected customers is unknown.
Regression
No, unconstrained relationships are a new feature in EF 11
Testing
Tests added.
Risk
Low. The behavior is limited to unconstrained relationships.