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 complex type discriminator. #35744

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndriySvyryd
Copy link
Member

@AndriySvyryd AndriySvyryd commented Mar 6, 2025

Breaking change: IDiscriminatorPropertySetConvention.ProcessDiscriminatorPropertySet signature changed

Part of #31376

Breaking change: IDiscriminatorPropertySetConvention.ProcessDiscriminatorPropertySet signature changed

Part of #31376
@AndriySvyryd AndriySvyryd force-pushed the Issue31376_Discriminator branch from 01dcbab to 459741f Compare March 7, 2025 20:28
@AndriySvyryd AndriySvyryd requested a review from Copilot March 8, 2025 00:18

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)
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.

1 participant