Repository navigation
[release/11.0] Fix FromSql queries with JSON-mapped complex properties - #39295
Merged
AndriySvyryd merged 4 commits intoOct 20, 2026
Merged
Conversation
Co-authored-by: AndriySvyryd <[email protected]>
Co-authored-by: AndriySvyryd <[email protected]>
Copilot
AI
changed the title
[WIP] Fix EF Core 11 FromSql regression for JSON complex property
Fix FromSql queries with JSON-mapped complex properties
Oct 16, 2026
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Release-branch metadata and compiled-model changes need functional and baseline test verification, which was not performed.
No open issues 🎉
What changed in this PR
Addresses #39251 by restoring FromSql materialization of JSON-mapped complex properties in EF Core 11.
Changes:
- Creates JSON container columns recursively in default mappings.
- Adds materialization, composed-query, and metadata regression coverage.
- Updates compiled-model assertions, generated baseline, and mapping guidance.
| File | Description |
|---|---|
| test/EFCore.SqlServer.FunctionalTests/Scaffolding/Baselines/ComplexTypes/DbContextModelBuilder.cs | Refreshes generated JSON mappings. |
| test/EFCore.SqlServer.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonMiscellaneousSqlServerTest.cs | Verifies successful queries and SQL baselines. |
| test/EFCore.Sqlite.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonMiscellaneousSqliteTest.cs | Verifies successful queries and SQLite SQL. |
| test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs | Tests JSON default mappings and nested metadata. |
| test/EFCore.Relational.Specification.Tests/Scaffolding/CompiledModelRelationalTestBase.cs | Scopes assertions to physical-table mappings. |
| test/EFCore.Relational.Specification.Tests/Query/Associations/ComplexJson/ComplexJsonMiscellaneousRelationalTestBase.cs | Adds synchronous and asynchronous composed queries. |
| src/EFCore.Relational/Metadata/Internal/RelationalModel.cs | Creates JSON containers during recursive default mapping. |
| .agents/skills/model-building/SKILL.md | Documents recursive JSON mapping requirements. |
Review effort: Balanced
Co-authored-by: AndriySvyryd <[email protected]>
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. |
cincuranet
approved these changes
Oct 20, 2026
artl93
approved these changes
Oct 20, 2026
artl93
left a comment
Member
There was a problem hiding this comment.
Regression. Customer reported. Approved.
AndriySvyryd
deleted the
copilot/fix-ef-core-11-null-reference-exception
branch
October 20, 2026 21:44
This was referenced Oct 21, 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 #39251
Description
FromSql/FromSqlRawqueries on entities with JSON-mapped complex properties were failing because default-table mappings flattened JSON members and omitted the container column required byGenerateComplexJsonShaper.Customer impact
The affected queries throw an exception. No known workaround. This isn't a common scenario, but it can be used as a workaround for other issues and unsupported features.
How found
Customer-reported on 11.0.0-rc1.
Regression
Yes, from EF Core 10.0.13
Testing
Tests added.
Risk
Low. The fix is rearranging code to also cover this case. Only
FromSqlqueries involving JSON complex properties would be affected.