Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

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.

Copilot AI changed the title [WIP] Fix behavior of relational type base extensions Port PR #37019 to release/10.0: Fix HasJsonPropertyName for complex JSON properties with backward compatibility Oct 23, 2025
Copilot AI requested a review from AndriySvyryd October 23, 2025 23:34
Copilot finished work on behalf of AndriySvyryd October 23, 2025 23:34
Copilot AI requested a review from AndriySvyryd October 24, 2025 01:01
Copilot finished work on behalf of AndriySvyryd October 24, 2025 01:01
@AndriySvyryd AndriySvyryd changed the base branch from main to release/10.0 October 24, 2025 01:04
@AndriySvyryd AndriySvyryd changed the title Port PR #37019 to release/10.0: Fix HasJsonPropertyName for complex JSON properties with backward compatibility [release/10.0] Fix HasJsonPropertyName for complex properties Oct 24, 2025
@AndriySvyryd AndriySvyryd force-pushed the copilot/fix-relational-extensions-behavior branch from 3cfc423 to 8272d1d Compare October 24, 2025 01:06
@AndriySvyryd AndriySvyryd marked this pull request as ready for review October 24, 2025 01:06
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner October 24, 2025 01:06
@AndriySvyryd
Copy link
Member

@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

Copy link
Contributor Author

Copilot AI commented Oct 24, 2025

@copilot Also add code to AnnotationCodeGenerator. GenerateFluentApiCalls(IComplexType,IDictionary<string, IAnnotation>) to handle the JsonPropertyName annotation. Verify by running Complex_types_mapp...

Done in 2909659. Added GenerateSimpleFluentApiCall for JsonPropertyName to the GenerateFluentApiCalls(IComplexType) method and removed it from the GenerateFluentApiCalls(IComplexProperty) method, so the annotation is now generated from the complex type where it's stored.

Copilot finished work on behalf of AndriySvyryd October 24, 2025 14:27
Copilot AI requested a review from AndriySvyryd October 24, 2025 14:59
Copilot finished work on behalf of AndriySvyryd October 24, 2025 14:59
@AndriySvyryd AndriySvyryd requested a review from roji October 24, 2025 15:40
Copy link
Member

@roji roji left a 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?

@AndriySvyryd
Copy link
Member

There's no release/10.0-staging yet

@SamMonoRT
Copy link
Member

Removing servicing consider label till all reviews/checks/CI is green. Please add it back when ready.

@AndriySvyryd
Copy link
Member

The failure was unrelated, fixed in #37022

@AndriySvyryd AndriySvyryd merged commit 25482a3 into release/10.0 Oct 31, 2025
8 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/fix-relational-extensions-behavior branch October 31, 2025 17:59
@SamMonoRT SamMonoRT added this to the 10.0.1 milestone Nov 3, 2025
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.

JSON property name is ignored in queries involving complex JSON types

5 participants