-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[release/10.0] Fix HasJsonPropertyName for complex properties #37020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release/10.0] Fix HasJsonPropertyName for complex properties #37020
Conversation
src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalTypeBaseExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalComplexPropertyExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalComplexPropertyExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalComplexPropertyExtensions.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Extensions/RelationalComplexPropertyExtensions.cs
Outdated
Show resolved
Hide resolved
Fixes #37009 Co-authored-by: AndriySvyryd <[email protected]>
3cfc423 to
8272d1d
Compare
|
@copilot Also add code to AnnotationCodeGenerator. GenerateFluentApiCalls(IComplexType,IDictionary<string, IAnnotation>) to handle the JsonPropertyName annotation. Verify by running Complex_types_mapped_to_json_are_stored_in_snapshot test |
…xProperty Co-authored-by: AndriySvyryd <[email protected]>
Done in 2909659. Added |
Co-authored-by: AndriySvyryd <[email protected]>
roji
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Am just not sure what the branch release/10.0 means at this stage - should we be targeting 10.0-staging as usual?
|
There's no |
|
Removing servicing consider label till all reviews/checks/CI is green. Please add it back when ready. |
|
The failure was unrelated, fixed in #37022 |
Fixes #37009
Port of #37019
Description
The issue was that HasJsonPropertyName() configuration on complex properties and complex collections within JSON columns was not working correctly because the annotation was being stored on the complex property instead of the complex type. This wasn't consistent with the way owned entity types are configured and wasn't expected by the query pipeline, which caused the reported issue.
Customer Impact
Apps with custom JSON property names on complex properties or complex collections within JSON columns using will throw an exception or return invalid data. This is a common scenario for developers that choose to map JSON columns as complex types and this is the recommended way of doing it starting with EF 10.
A workaround is to use
.HasTypeAnnotation(RelationalAnnotationNames.JsonPropertyName, name)How found
Reported on 10.0.0-rc2
Regression
No, this is a new feature
Testing
Test added
Risk
Low - The changes are surgical and focused on JSON property name configuration handling for complex types. The annotation code generator now correctly generates HasJsonPropertyName() from both complex type and complex property annotations to support the backward compatibility quirk. Quirk added for backward compatibility.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.