Repository navigation
Fix JSON complex property projections with identity resolution - #39442
Merged
AndriySvyryd merged 1 commit intoOct 30, 2026
Merged
AndriySvyryd merged 1 commit into
AndriySvyryd merged 1 commit into
Conversation
- Restrict JSON entity order validation to entity types - Add sync and async projection regression tests for SQLite and SQL Server Fixes dotnet#39322
Contributor
Author
|
@dotnet-policy-service agree |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the targeted JSON complex-property projection fix.
No open issues 🎉
What changed in this PR
This pull request fixes an InvalidCastException when projecting JSON-mapped complex properties with AsNoTrackingWithIdentityResolution(). Entity-order validation is now limited to entity metadata, allowing complex properties to materialize correctly.
Changes:
- Restricts JSON identity-order validation to entity shapers.
- Adds synchronous and asynchronous regression tests for anonymous and member-initializer projections.
- Adds SQLite and SQL Server SQL baselines covering required and optional complex properties.
| File | Description |
|---|---|
test/EFCore.SqlServer.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonProjectionSqlServerTest.cs |
Adds SQL Server SQL baselines for the new regression tests. |
test/EFCore.Sqlite.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonProjectionSqliteTest.cs |
Adds SQLite SQL baselines for the new regression tests. |
test/EFCore.Relational.Specification.Tests/Query/Associations/ComplexJson/ComplexJsonProjectionRelationalTestBase.cs |
Adds shared regression tests for required and optional JSON complex properties. |
src/EFCore.Relational/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs |
Restricts identity-resolution JSON ordering validation to entity shapers. |
Review effort: Lite
AndriySvyryd
approved these changes
Oct 30, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
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.
Projecting a JSON-mapped complex property with
AsNoTrackingWithIdentityResolution()throws anInvalidCastExceptionbecause the JSON entity order validator casts complex type metadata toIEntityType.Restrict entity order validation to entity types, allowing complex properties to be materialized without treating them as entities with independent identity.
Add regression tests for anonymous and member-initializer projections, covering required and optional complex properties with synchronous and asynchronous execution on SQLite and SQL Server.
Validation:
Fixes #39322