-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add support for complex type discriminator. #35744
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
Conversation
862c4d7
to
c8fa6b5
Compare
01dcbab
to
459741f
Compare
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.
PR Overview
This PR adds support for complex type discriminators and updates related APIs and conventions by breaking the signature of IDiscriminatorPropertySetConvention.ProcessDiscriminatorPropertySet. Key changes include the introduction of new builders/interfaces for complex type discriminators, modifications to model validation and snapshot generation, and adjustments in convention dispatcher implementations to support the new discriminator configuration on both entity and complex types.
Reviewed Changes
File | Description |
---|---|
src/EFCore/Metadata/Builders/IConventionComplexTypeDiscriminatorBuilder.cs | New interface to provide a simple API for configuring complex type discriminators. |
src/EFCore/Metadata/Builders/ComplexTypeDiscriminatorBuilder`.cs | New implementation for configuring discriminator values for complex types (note the extraneous backtick in the filename). |
src/EFCore/Infrastructure/ModelValidator.cs | Updates to validate discriminator values for both entity and complex types. |
src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs | Adjustments to generate fluent API calls for discriminator configuration in the snapshot. |
src/EFCore.Cosmos/Metadata/Conventions/CosmosJsonIdConvention.cs | Changes refactoring chained calls for discriminator configuration on Cosmos DB. |
src/EFCore/Metadata/Conventions/DiscriminatorConvention.cs | Updated signature handling in discriminator processing to support IConventionTypeBaseBuilder. |
Other files (ConventionDispatcher, IConventionTypeBaseBuilder, etc.) | Various updates across the conventions infrastructure to support the breaking change. |
Copilot reviewed 67 out of 67 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
src/EFCore/Metadata/Builders/ComplexTypeDiscriminatorBuilder`.cs:1
- The file name 'ComplexTypeDiscriminatorBuilder`.cs' contains an extraneous backtick; consider renaming it to 'ComplexTypeDiscriminatorBuilder.cs' for consistency.
+// Licensed to the .NET Foundation under one or more agreements.
src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs:1960
- [nitpick] Consider adding tests that explicitly cover the validation of discriminator values on nested complex types to ensure comprehensive validation.
+ foreach (var complexProperty in derivedType.GetDeclaredComplexProperties())
src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.DelayedConventionScope.cs:83
- [nitpick] Ensure that the use of 'structuralTypeBuilder' for the parameter in OnDiscriminatorPropertySet is consistently applied across all dispatcher implementations for clarity.
public override string? OnDiscriminatorPropertySet(IConventionTypeBaseBuilder structuralTypeBuilder, string? name)
This will need updating the breaking change documentation. |
|
Breaking change: IDiscriminatorPropertySetConvention.ProcessDiscriminatorPropertySet signature changed Part of #31376
459741f
to
7d58130
Compare
Breaking change:
IDiscriminatorPropertySetConvention.ProcessDiscriminatorPropertySet
signature changedPart of #31376