Skip to content

Cosmos DB: Issues with surrogate PK design in preview 3 #13633

@divega

Description

@divega

I haven't fully tested that this is an issue but I wanted to capture it before I forget:

  • With the current design we do not guarantee uniqueness of "real" key values across multiple instances of DbContext. E.g. you can save a customer with a CustomerId = 1 even if one already exists in the database
  • Disconnected scenarios (for example, using Attach) do not populate the surrogate key in shadow state, and therefore it wouldn't be possible to update or delete an existing entity without additional roundrips

@smitpatel and I discussed briefly that a design that creates the value for id deterministically based on actual values on properties could address this, but such design may have other problems.

Note that if we want entity hierarchies to share key space, we should use the discriminator value of the base type when we construct the id.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions