Repository navigation
Document Cosmos single-value ID escaping breaking change in EF Core 10 - #5557
AndriySvyryd wants to merge 3 commits into
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 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. |
There was a problem hiding this comment.
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. | ||
|
|
There was a problem hiding this comment.
@copilot Link the breaking change in EF 11 that stops escaping for composite ids as well
There was a problem hiding this comment.
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>

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.