Skip to content

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

Draft
AndriySvyryd with Copilot wants to merge 1 commit into
preview.7from
copilot/implement-issue-5418
Draft

Document breaking change: Cosmos undefined projections now throw (EF Core 11)#5433
AndriySvyryd with Copilot wants to merge 1 commit 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
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.

2 participants