-
Notifications
You must be signed in to change notification settings - Fork 40
EF-285: Map discriminator to "_t" unless it has been explicitly configured #275
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
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.
Pull request overview
This PR fixes an issue where naming conventions (like CamelCase) were overriding the default discriminator element name. It introduces a new MongoDiscriminatorNamingConvention that runs during model finalization to ensure discriminators are mapped to "_t" unless explicitly configured otherwise.
Changes:
- Added
MongoDiscriminatorNamingConventionto preserve "_t" as the discriminator element name - Registered the new convention in
MongoConventionSetBuilder - Refactored test infrastructure to use generic
CamelCaseDbContext<T>for easier test creation - Added three test cases to verify discriminator naming behavior with CamelCase convention
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/MongoDB.EntityFrameworkCore/Metadata/Conventions/MongoDiscriminatorNamingConvention.cs |
New convention that ensures discriminators use "_t" unless explicitly configured |
src/MongoDB.EntityFrameworkCore/Metadata/Conventions/MongoConventionSetBuilder.cs |
Registers the new discriminator naming convention |
tests/MongoDB.EntityFrameworkCore.FunctionalTests/Metadata/Conventions/CamelCaseElementNameConventionTests.cs |
Refactored test context and added three test cases for discriminator preservation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ityFrameworkCore.FunctionalTests/Metadata/Conventions/CamelCaseElementNameConventionTests.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.EntityFrameworkCore/Metadata/Conventions/MongoDiscriminatorNamingConvention.cs
Show resolved
Hide resolved
...ityFrameworkCore.FunctionalTests/Metadata/Conventions/CamelCaseElementNameConventionTests.cs
Outdated
Show resolved
Hide resolved
...ityFrameworkCore.FunctionalTests/Metadata/Conventions/CamelCaseElementNameConventionTests.cs
Outdated
Show resolved
Hide resolved
src/MongoDB.EntityFrameworkCore/Metadata/Conventions/MongoDiscriminatorNamingConvention.cs
Outdated
Show resolved
Hide resolved
damieng
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.
Let's update BREAKING-CHANGES.md with a new section for the next release with notes about this and the potential for throwing now the new name is _t if they were previously using CamelCaseNamingConvention.
…gured This reverts any clobbering by naming conventions.
|
Updated breaking changes doc. |
This reverts any clobbering by naming conventions.