Skip to content

Document Cosmos discriminator naming breaking change (EF Core 11) - #5391

Merged
cincuranet merged 5 commits into
preview.7from
copilot/document-discriminator-naming-change
Jun 24, 2026
Merged

Document Cosmos discriminator naming breaking change (EF Core 11)#5391
cincuranet merged 5 commits into
preview.7from
copilot/document-discriminator-naming-change

Conversation

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Documents the EF Core 11 breaking change from efcore#38458: the default Azure Cosmos DB discriminator property is now named Discriminator in the EF model again, while the property written to the JSON document remains $type by default. The model name and JSON name are now decoupled, so stored documents are unaffected.

Changes

  • ef-core-11.0/breaking-changes.md — New low-impact entry (summary-table row + section):
    • Old: $type used as both the model property name and the JSON name; an invalid C# identifier that produced uncompilable code for compiled models / precompiled queries (Native AOT).
    • New: model name reverts to Discriminator; JSON name stays $type. On-disk format unchanged.
    • Mitigations: none needed for stored data; update code that references the model name $type; set the JSON name model-wide via HasEmbeddedDiscriminatorName; per-entity via ToJsonProperty; or restore the old model name with HasDiscriminator<string>("$type").
    • Examples: show how to align the JSON discriminator name with the model property name by configuring it as Discriminator.
  • providers/cosmos/modeling.md — Note clarifying model name vs JSON name and documenting the previously undocumented model-wide HasEmbeddedDiscriminatorName API, including an example that aligns the JSON discriminator name with the model property name.

Setting the JSON name to match the model name

modelBuilder.HasEmbeddedDiscriminatorName("Discriminator");

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Documents an EF Core 11 Cosmos DB breaking change where the discriminator’s model property name is Discriminator again while the JSON property name remains $type by default, clarifying that stored documents are unaffected.

Changes:

  • Adds a new low-impact breaking change entry describing the discriminator model-name vs JSON-name decoupling and mitigations.
  • Updates Cosmos modeling docs with an EF Core 11 note and documents the model-wide HasEmbeddedDiscriminatorName API.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md Adds a new EF Core 11 breaking-change section and summary-table row explaining the Cosmos discriminator naming change and mitigations.
entity-framework/core/providers/cosmos/modeling.md Adds a note clarifying model vs JSON discriminator naming and points readers to the EF Core 11 breaking change entry.

Comment thread entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md Outdated
Comment thread entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md Outdated
Comment thread entity-framework/core/providers/cosmos/modeling.md Outdated
Comment thread entity-framework/core/providers/cosmos/modeling.md Outdated
@AndriySvyryd
AndriySvyryd marked this pull request as ready for review June 24, 2026 04:52
@AndriySvyryd
AndriySvyryd requested a review from cincuranet June 24, 2026 04:57
@cincuranet
cincuranet merged commit ebc3911 into preview.7 Jun 24, 2026
5 checks passed
@cincuranet
cincuranet deleted the copilot/document-discriminator-naming-change branch June 24, 2026 09:48
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.

4 participants