[release/10.0] Fix ExecuteUpdate over scalar projections#37791
Open
roji wants to merge 1 commit intodotnet:release/10.0from
Open
[release/10.0] Fix ExecuteUpdate over scalar projections#37791roji wants to merge 1 commit intodotnet:release/10.0from
roji wants to merge 1 commit intodotnet:release/10.0from
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a regression where ExecuteUpdate fails when preceded by a Select projecting to a scalar-only anonymous type, by avoiding application of the pending selector when it contains only scalar projections.
Changes:
- Guard pending selector application in
NavigationExpandingExpressionVisitor.ProcessExecuteUpdatebased onSnapshotExpressionstructure (and add an Issue37771 quirk switch). - Add relational spec tests covering scalar-only and mixed entity+scalar anonymous projections before
ExecuteUpdate. - Add provider-specific SQL baselines for the new tests (SQLite, SQL Server).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs | Skips applying the pending selector when its snapshot is a DefaultExpression, preserving property binding for scalar-only projections. |
| test/EFCore.Relational.Specification.Tests/BulkUpdates/NorthwindBulkUpdatesRelationalTestBase.cs | Adds new tests for ExecuteUpdate over scalar-only and mixed projections (#37771). |
| test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs | Adds SQLite SQL baselines for the new tests. |
| test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs | Adds SQL Server SQL baselines for the new tests. |
test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs
Show resolved
Hide resolved
test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs
Show resolved
Hide resolved
AndriySvyryd
approved these changes
Feb 25, 2026
artl93
approved these changes
Feb 25, 2026
Member
artl93
left a comment
There was a problem hiding this comment.
Approved. Servicing regression, customer reported.
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 #37771
Description
When ExecuteUpdate is preceded by a Select that projects to a scalar-only anonymous type (e.g. select new { p.Used, n.Qty }), the query fails with "The following lambda argument to 'SetProperty' does not represent a valid property to be set". This happens because the fix for #37247 (PR #37262) unconditionally applies the pending selector before processing ExecuteUpdate setters. When the pending selector contains only scalar values (no entity references), applying it loses the connection between the projected scalars and the original entity properties, so ExecuteUpdate can no longer resolve which column to update.
The fix guards this pending selector application: it is only applied when the snapshot of the pending selector contains entity/structural type references (i.e. is not a DefaultExpression). When all projected members are scalars, the pending selector is skipped, preserving the original entity property binding.
Customer impact
Any ExecuteUpdate query that is preceded by a Select projecting to an anonymous type containing only scalar properties fails at query translation time. No data corruption occurs — the query throws before executing. There is no feasible workaround other than using the quirk to disable #37247, downgrading to 10.0.1 or restructuring the query to avoid the scalar projection.
How found
User reported on 10.0.2/10.0.3. A second user reported a potentially related issue in the comments. 1 upvote, 2 comment authors affected.
Regression
Yes. Regression from 10.0.1, introduced in 10.0.2 by PR #37262 (fix for #37247).
Testing
4 new tests added (2 test methods × sync/async): one for scalar-only anonymous projection, one for mixed entity+scalar anonymous projection.
Risk
Very low. The product code change is a single conditional guard (wrapping existing code in if (newStructure is not DefaultExpression)). The original #37247 fix continues to work — its existing test still passes. Quirk added.