Skip to content

[release/11.0] Preserve ExecuteUpdate target joins during SQL tree pruning - #39128

Merged
AndriySvyryd merged 3 commits into
release/11.0from
copilot/fix-ef-core-11-update-target-join
Oct 1, 2026
Merged

AndriySvyryd merged 3 commits into
release/11.0from
copilot/fix-ef-core-11-update-target-join

Conversation

Copilot AI commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #39124

Description
EF Core could prune a required one-to-one join used as the ExecuteUpdate target, producing an UPDATE alias absent from FROM and failing with SQL Server error. This is fixed by marking the update-target alias as referenced.

Customer impact
ExecuteUpdate call that affects a related one-to-one now throws an error.

var affected = context.Roots.ExecuteUpdate(s => s
    .SetProperty(r => r.RequiredAssociate.String, "foo_updated")
    .SetProperty(r => r.RequiredAssociate.Int, 20));

How found
User reported on EF Core 11.0.0-rc1. This is a fairly common case.

Regression
Yes, from EF Core 10.x, introduced by #37819

Testing
Tests added.

Risk
Low. The fix is minimal and only affects pruning behavior.

Copilot AI and others added 2 commits September 30, 2026 00:47
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix EF Core 11 relational regression with ExecuteUpdate Preserve ExecuteUpdate target joins during SQL tree pruning Sep 30, 2026
Copilot AI requested a review from AndriySvyryd September 30, 2026 00:56
@AndriySvyryd AndriySvyryd changed the title Preserve ExecuteUpdate target joins during SQL tree pruning [release/11.0] Preserve ExecuteUpdate target joins during SQL tree pruning Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review issues remain.

Review effort: Lite
Findings: None

What changed in this PR

Fixes SQL Server ExecuteUpdate failures by preserving joins referenced by update-target columns during SQL tree pruning.

Changes:

  • Visits setter target columns before pruning.
  • Adds regression coverage for navigation and primitive-collection updates.
File Description
test/​EFCore.SqlServer.FunctionalTests/​Query/​Associations/​Navigations/​NavigationsBulkUpdateSqlServerTest.cs Verifies generated SQL and successful updates.
src/​EFCore.Relational/​Query/​SqlTreePruner.cs Preserves update-target joins during pruning.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@AndriySvyryd
AndriySvyryd marked this pull request as ready for review September 30, 2026 02:10
@AndriySvyryd
AndriySvyryd requested a review from a team as a code owner September 30, 2026 02:10
@github-code-quality

github-code-quality Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage

The overall line coverage in commit 17933de in the copilot/fix-ef-core-... branch remains at 67%, unchanged from commit e2d4df3 in the release/11.0 branch.

Show a line coverage summary of the most impacted files.
File release/11.0 e2d4df3 copilot/fix-ef-core-... 17933de +/-
/Users/runner/w...ReaderWriter.cs 63% 0% -63%
/Users/runner/w...rTypeMapping.cs 81% 56% -25%
D:\a\efcore\efc...rTypeMapping.cs 81% 56% -25%
D:\a\efcore\efc...ssionVisitor.cs 96% 93% -3%
/Users/runner/w...ionGenerator.cs 100% 99% -1%
/home/runner/wo...ionGenerator.cs 100% 99% -1%
D:\a\efcore\efc...ionGenerator.cs 100% 99% -1%
/Users/runner/w...ssionVisitor.cs 79% 81% +2%
D:\a\efcore\efc...ssionFactory.cs 84% 88% +4%
/home/runner/wo...ssionFactory.cs 83% 88% +5%

Updated October 01, 2026 18:47 UTC

@AndriySvyryd
AndriySvyryd requested a review from artl93 October 1, 2026 18:29

@artl93 artl93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User reported regression. Approved.

@AndriySvyryd
AndriySvyryd merged commit e892e3d into release/11.0 Oct 1, 2026
41 of 42 checks passed
@AndriySvyryd
AndriySvyryd deleted the copilot/fix-ef-core-11-update-target-join branch October 1, 2026 19:39
@rbhanda rbhanda added this to the 11.0.0 milestone Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EF Core 11 relational regression: ExecuteUpdate prunes its update-target join

6 participants