Skip to content

Document EF Core 9 breaking change: NoTrackingWithIdentityResolution restricted for JSON collection queries#5413

Merged
AndriySvyryd merged 5 commits into
mainfrom
copilot/document-breaking-change-notrackidentityresol
Jul 7, 2026
Merged

Document EF Core 9 breaking change: NoTrackingWithIdentityResolution restricted for JSON collection queries#5413
AndriySvyryd merged 5 commits into
mainfrom
copilot/document-breaking-change-notrackidentityresol

Conversation

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #4932

Using AsNoTrackingWithIdentityResolution() with JSON-mapped entity collections could silently corrupt data or throw unhelpful exceptions in EF Core 8 and earlier, due to how JSON is streamed and materialized. EF Core 9 adds a validator and explicit prohibitions to surface these problems clearly.

Changes

  • Summary table: Added Low-impact entry for the new restriction in ef-core-9.0/breaking-changes.md
  • Breaking change section: Documents the full behavior change — old (silent corruption / cryptic StartObject exception), new (explicit exception), why (key values not propagated for JSON collection queryable operators → null keys), and mitigations

Prohibited pattern (now throws)

var blogs = await context.Blogs
    .AsNoTrackingWithIdentityResolution()
    .Select(b => new
    {
        Blog = b,
        TopPosts = b.JsonPosts.OrderBy(p => p.Rating).Take(3).ToList() // ❌ queryable operator on JSON collection
    })
    .ToListAsync();

Mitigations

Switch to AsTracking() (for identity resolution) or AsNoTracking() (no deduplication needed).

Copilot AI changed the title [WIP] Add validator for entity materialization order Document EF Core 9 breaking change: NoTrackingWithIdentityResolution restricted for JSON collection queries Jul 3, 2026
Copilot AI requested a review from AndriySvyryd July 3, 2026 02:00
@AndriySvyryd AndriySvyryd requested a review from Copilot July 3, 2026 02:10

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 9 breaking change that prohibits certain AsNoTrackingWithIdentityResolution() query patterns involving JSON-mapped entity collections, to prevent incorrect materialization and to surface clearer exceptions.

Changes:

  • Added a new Low-impact entry to the EF Core 9 breaking changes summary table.
  • Added a new breaking change section describing old vs. new behavior, rationale, and mitigations (switch to AsTracking() or AsNoTracking()).

Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md Outdated
Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread entity-framework/core/what-is-new/ef-core-9.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

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

Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md Outdated
Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 3, 2026 04:47

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md
Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md
Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md
Comment thread entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md
@AndriySvyryd AndriySvyryd merged commit f62650a into main Jul 7, 2026
6 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/document-breaking-change-notrackidentityresol branch July 7, 2026 20:03
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 breaking change around NoTrackingWithIdentityResolution (disabled scenario)

4 participants