Skip to content

Document Cosmos single-value ID escaping breaking change in EF Core 10 - #5557

Draft
AndriySvyryd wants to merge 3 commits into
mainfrom
copilot/fix-cosmos-ef-core-10-issue
Draft

AndriySvyryd wants to merge 3 commits into
mainfrom
copilot/fix-cosmos-ef-core-10-issue

Conversation

@AndriySvyryd

@AndriySvyryd AndriySvyryd commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

EF Core 10 no longer escapes single-value Cosmos JSON IDs, causing point reads to miss existing escaped IDs and potentially allowing duplicate documents. This behavior was missing from the breaking-change documentation.

  • Behavior: Add a medium-impact entry with before/after examples, affected characters, and unchanged escaping for multi-value IDs.
  • Mitigations: Explain document migration, invalid-character handling, and the absence of an escaping-only compatibility option; flag internal API replacement risks.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@AndriySvyryd AndriySvyryd changed the title [WIP] Fix Cosmos undocumented breaking change in EF Core 10 Document Cosmos single-value ID escaping breaking change in EF Core 10 Dec 3, 2026
@AndriySvyryd
AndriySvyryd requested a lite review from Copilot December 3, 2026 23:45

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.

🟡 Changes recommended

The migration guidance remains incomplete for containers whose partition key is /id because it does not explicitly explain using the old and new partition-key values during delete and create operations.

1 open issue
What changed in this PR

Documents the EF Core 10 Cosmos DB single-value ID escaping breaking change and migration considerations.

Changes:

  • Adds a medium-impact breaking-change entry with before/after examples.
  • Explains affected characters, multi-value IDs, and compatibility limitations.
  • Documents migration and encoding mitigations.
File Description
entity-framework/​core/​what-is-new/​ef-core-10.0/​breaking-changes.md Adds comprehensive documentation for the Cosmos single-value ID escaping change, including behavior, migration guidance, and compatibility considerations.

Review effort: Lite


#### Mitigations

Before upgrading, check whether existing documents have escaped single-value IDs. If so, migrate them to the new ID format, for example using the Azure Cosmos DB SDK. Cosmos DB does not support changing an existing document's `id` in place, so create a document with the new ID and then delete the old document. Preserve partition key values and other application data, and handle any conflicts with documents already using the new ID. If key values contain characters that Cosmos DB does not allow in IDs, use a valid encoding and configure the model accordingly rather than simply removing the escaping.

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.

Updated the migration guidance to explicitly use the old escaped ID as the partition key when deleting the old document and the new unescaped ID when creating the replacement when the partition-key path is /id. Commit: 0726f55.

Escaping is unchanged for IDs composed of multiple values, including those containing a discriminator.

Existing documents with escaped IDs are not updated automatically. Point reads, including queries optimized to point reads, now use the unescaped ID and therefore don't find these documents. An existence check followed by an insert can consequently create a second document for the same logical key. Values containing characters that Cosmos DB does not allow in IDs can now be rejected instead of being escaped.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot Link the breaking change in EF 11 that stops escaping for composite ids as well

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.

Linked the EF Core 11 breaking change covering removal of escaping for composite IDs. Commit: 0726f55.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.

Cosmos: undocumented breaking change in EF Core 10, single-value key ids are no longer escaped

3 participants