CosmosDB: Nested embedded entities get rearranged on deletion #27272
Labels
area-cosmos
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Milestone
Overview
I'm working on a project that has a Cosmos DB container that contains multiple levels of nested embedded entities. We started to notice strange behavior that I've ultimately tracked down to an interaction between EF and CosmosDB. This behavior occurs when deleting middle level embedded entities from a CosmosDB record. When the middle level embedded entity is deleted, its inner child entities which we would expect to also be deleted are instead rearranged to point to a different middle level entity.
Example
We have three levels of entities:
The OuterEntity owns many MiddleEntities and the MiddleEntity owns many InnerEntities
After we delete the first MiddleEntity, the one remaining MiddleEntity now contains the wrong InnerEntity
Code Example
This example is easily reproducible with a small program run against the local cosmos db emulator
Code Output
The code above produces the following ouput to the console:
Clearly, this is not expected. The output we would expect if the Middle1 record was properly deleted would be:
EF provider and version information
I have tested and confirmed this behavior with two configurations to prove that this bug is present in both EF 5 and EF 6:
EF 5 config:
EF 6 config:
The text was updated successfully, but these errors were encountered: