Skip to content

Document breaking change: Cosmos undefined projections now throw (EF Core 11) - #5433

Merged
cincuranet merged 3 commits into
preview.7from
copilot/implement-issue-5418
Jul 30, 2026
Merged

Document breaking change: Cosmos undefined projections now throw (EF Core 11)#5433
cincuranet merged 3 commits into
preview.7from
copilot/implement-issue-5418

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

EF Core 11 (dotnet/efcore#38550) changed Azure Cosmos DB projection behavior: anonymous/DTO projections that previously silently dropped undefined values (single-property via SELECT VALUE) or threw cryptic Nullable object must have a value exceptions (multi-property) now consistently throw InvalidOperationException: "A part of the projection was undefined, use the coalesce operator to handle possible undefined values."

Changes

  • ef-core-11.0/breaking-changes.md — Medium-impact entry in summary table + full section: old/new behavior, rationale, mitigations via IsDefined / CoalesceUndefined
  • ef-core-11.0/whatsnew.md — Brief Cosmos DB section on the behavior change with link to breaking changes
  • providers/cosmos/querying.md — New "Undefined values in projections" section explaining when undefined occurs and how to handle it

Mitigation pattern

// Filter out documents where the nested path is absent
var results = await context.Entities
    .Where(x => EF.Functions.IsDefined(x.Associate!.NestedAssociate!.Id))
    .Select(x => new { x.Associate!.NestedAssociate!.Id })
    .ToListAsync();

// Or coalesce to a default
var results = await context.Entities
    .Select(x => new { Id = EF.Functions.CoalesceUndefined(x.Associate!.NestedAssociate!.Id, Guid.Empty) })
    .ToListAsync();

Copilot AI changed the title Document breaking change for Cosmos undefined projections (EF Core 11) Document breaking change: Cosmos undefined projections now throw (EF Core 11) Jul 28, 2026
Copilot AI requested a review from AndriySvyryd July 28, 2026 00:27
@AndriySvyryd
AndriySvyryd requested a review from Copilot July 28, 2026 23:06

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 for the Azure Cosmos DB provider: projections that evaluate to Cosmos undefined now consistently throw a clear InvalidOperationException, and provides mitigation guidance.

Changes:

  • Adds a new EF Core 11 breaking change entry describing old/new behavior, rationale, and mitigations (IsDefined, CoalesceUndefined).
  • Adds a brief “What’s New” note for Cosmos projections with a link to the breaking changes entry.
  • Adds provider documentation explaining when undefined occurs in Cosmos and how to handle it in projections.

Reviewed changes

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

File Description
entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md Adds a Cosmos “undefined in projections” note and links to the breaking changes entry.
entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md Adds a medium-impact breaking change section detailing the projection behavior change and mitigations.
entity-framework/core/providers/cosmos/querying.md Adds provider guidance for handling undefined values in anonymous/DTO projections.

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
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread entity-framework/core/providers/cosmos/querying.md
Comment thread entity-framework/core/what-is-new/ef-core-11.0/breaking-changes.md Outdated
Copilot AI requested a review from AndriySvyryd July 28, 2026 23:20
@AndriySvyryd
AndriySvyryd marked this pull request as ready for review July 28, 2026 23:30
@AndriySvyryd
AndriySvyryd requested a review from cincuranet July 28, 2026 23:31
@cincuranet
cincuranet merged commit 972e4ef into preview.7 Jul 30, 2026
5 checks passed
@cincuranet
cincuranet deleted the copilot/implement-issue-5418 branch July 30, 2026 09:09
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