Skip to content
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

Add support for optional complex types to model building #35614

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

AndriySvyryd
Copy link
Member

@AndriySvyryd AndriySvyryd commented Feb 11, 2025

Breaking change: uniquify and validate complex type column uniqueness

Part of #31376

@AndriySvyryd AndriySvyryd force-pushed the Issue31376_ModelBuilding branch from 82670a4 to 64afeec Compare February 11, 2025 06:18
Breaking change: uniquify and validate complex type columns

Part of #31376
@AndriySvyryd AndriySvyryd force-pushed the Issue31376_ModelBuilding branch from 64afeec to 8cea586 Compare February 28, 2025 20:00
@AndriySvyryd AndriySvyryd marked this pull request as ready for review February 28, 2025 20:01
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner February 28, 2025 20:01
@AndriySvyryd AndriySvyryd requested a review from Copilot February 28, 2025 20:27

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request adds support for optional complex types to model building along with breaking changes to uniquify and validate complex type column uniqueness. Key changes include adding new APIs and configuration for complex property mapping in test and production code, modifying error conditions for complex properties, and renaming variables for clarity in runtime annotation code generation.

Reviewed Changes

File Description
test/EFCore.Relational.Specification.Tests/LazyLoadProxyRelationalTestBase.cs New test base for configuring complex properties with lazy loading proxies.
src/EFCore.Relational/Metadata/Conventions/SharedTableConvention.cs Updates for determining uniqueness of complex property columns.
src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs Refinements for ownership and complex type column naming logic.
src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs Additional validation for complex property mapping and concurrency token checks.
src/EFCore.Relational/Metadata/Internal/ComplexProperty.cs Enforces non-nullability for complex properties that are collections.
test/EFCore.Relational.Specification.Tests/Migrations/MigrationsTestBase.cs Test changes for column naming and nullability assertions.
src/EFCore.Relational/Design/Internal/RelationalCSharpRuntimeAnnotationCodeGenerator.cs Renamed variable for clarity in generating runtime annotations.

Copilot reviewed 35 out of 35 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

src/EFCore.Relational/Metadata/Conventions/SharedTableConvention.cs:240

  • Ensure that using GetIdentifyingMemberInfo correctly handles all cases for both entity and complex types; add unit tests to cover edge cases if they are not already present.
var identifyingMemberInfo = property.GetIdentifyingMemberInfo();

src/EFCore/Metadata/Internal/ComplexProperty.cs:149

  • The new check throws when a complex property marked as a collection is set to optional; please confirm that this breaking behavior is intentional and update documentation accordingly.
if (IsCollection) { throw new InvalidOperationException(CoreStrings.ComplexPropertyOptional(DeclaringType.DisplayName(), Name)); }

src/EFCore.Relational/Design/Internal/RelationalCSharpRuntimeAnnotationCodeGenerator.cs:1501

  • The renaming to 'structuralTypeVariable' improves clarity over the previous 'entityTypeVariable'; please verify that all references have been updated consistently.
string structuralTypeVariable,

test/EFCore.Relational.Specification.Tests/Migrations/MigrationsTestBase.cs:2710

  • [nitpick] Using Assert.True enhances readability; ensure that tests comprehensively cover scenarios for both required and optional complex properties.
Assert.True(c.IsNullable);
@SamMonoRT
Copy link
Member

LGTM - only question was is there any performance implications with JIT or also NAOT scenario here?

@SamMonoRT
Copy link
Member

Also for the new strings added, do we need any localization folks on review to trigger any follow up loc action?

@AndriySvyryd
Copy link
Member Author

LGTM - only question was is there any performance implications with JIT or also NAOT scenario here?

No, this has no perf impact

Also for the new strings added, do we need any localization folks on review to trigger any follow up loc action?

We don't localize our strings

@AndriySvyryd AndriySvyryd merged commit 34ee81a into main Mar 6, 2025
7 checks passed
@AndriySvyryd AndriySvyryd deleted the Issue31376_ModelBuilding branch March 6, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants