Skip to content

Conversation

@ajcvickers
Copy link
Collaborator

This reverts any clobbering by naming conventions.

@ajcvickers ajcvickers requested a review from damieng January 21, 2026 13:34
@ajcvickers ajcvickers requested a review from a team as a code owner January 21, 2026 13:34
Copilot AI review requested due to automatic review settings January 21, 2026 13:34
Copy link
Contributor

Copilot AI left a 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 MongoDiscriminatorNamingConvention to 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.

Copy link
Collaborator

@damieng damieng left a 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.

@ajcvickers
Copy link
Collaborator Author

Updated breaking changes doc.

@ajcvickers ajcvickers requested a review from damieng January 27, 2026 11:30
@ajcvickers ajcvickers added the bug Something isn't working label Feb 2, 2026
@ajcvickers ajcvickers requested a review from damieng February 2, 2026 14:42
@ajcvickers ajcvickers merged commit 0488aca into main Feb 3, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants