Skip to content

Document obsoletion of owned JSON collections without an explicit key (EF11)#5383

Merged
AndriySvyryd merged 5 commits into
preview.6from
copilot/document-json-owned-entity-obsoletion
Jun 11, 2026
Merged

Document obsoletion of owned JSON collections without an explicit key (EF11)#5383
AndriySvyryd merged 5 commits into
preview.6from
copilot/document-json-owned-entity-obsoletion

Conversation

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Per dotnet/efcore#38395, EF Core 11 raises an OwnedEntityMappedToJsonCollectionWarning when an owned type is mapped to JSON as a collection without an explicit primary key (synthetic ordinal key). The original broader deprecation proposed in dotnet/efcore#37290 was narrowed to just this case.

Changes

  • entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md
    • New low-impact entry #owned-json-collections-obsolete following the standard Old/New/Why/Mitigations template.
    • Added corresponding row to the summary table.
    • Recommended mitigation: migrate to complex-type JSON mapping (the preferred mapping since EF 10). Fallback: configure an explicit key on the owned type, or suppress the warning via ConfigureWarnings.
// Before — now raises OwnedEntityMappedToJsonCollectionWarning
modelBuilder.Entity<Blog>().OwnsMany(b => b.Posts, b => b.ToJson());

// Recommended
modelBuilder.Entity<Blog>().ComplexCollection(b => b.Posts, b => b.ToJson());

// Or keep OwnsMany with an explicit key
modelBuilder.Entity<Blog>().OwnsMany(b => b.Posts, b =>
{
    b.ToJson();
    b.HasKey(p => p.Id);
});

// Or suppress the warning via configuration
optionsBuilder.ConfigureWarnings(w => w.Ignore(CoreEventId.OwnedEntityMappedToJsonCollectionWarning));

The new anchor is the intended target for the existing aka.ms/efcore-docs-json-owned-entities redirect (redirect update handled separately).

Copilot AI changed the title [WIP] Document the obsoletion of JSON owned entity support as breaking change Document obsoletion of owned JSON collections without an explicit key (EF11) Jun 10, 2026
Copilot AI requested a review from AndriySvyryd June 10, 2026 23:16
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

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 breaking-change/deprecation: owned types mapped to JSON collections without an explicit primary key now raise OwnedEntityMappedToJsonCollectionWarning, and the pattern is considered obsolete going forward.

Changes:

  • Adds a new low-impact breaking-changes entry (#owned-json-collections-obsolete) using the standard Old/New/Why/Mitigations structure.
  • Updates the breaking changes summary table to include the new entry.
  • Provides mitigations: prefer ComplexCollection(...).ToJson(), or keep OwnsMany(...).ToJson() with an explicit key, or suppress via ConfigureWarnings.

Comment thread entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@AndriySvyryd AndriySvyryd marked this pull request as ready for review June 11, 2026 00:07
@AndriySvyryd AndriySvyryd requested a review from SamMonoRT June 11, 2026 00:08
@AndriySvyryd AndriySvyryd merged commit 2298451 into preview.6 Jun 11, 2026
5 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/document-json-owned-entity-obsoletion branch June 11, 2026 19:36
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.

Document the obsoletion of JSON owned entity support

4 participants