-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cosmos: Use 1:1 mapping for .NET Id
to JSON id
unless explicitly configured otherwise
#34179
Comments
Just for completeness, mentioning @divega's additional suggestion of allowing users to integrate a discriminator into |
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Fixes #34179 There are also new APIs on the entity type and model builders to facilitate optional behaviors, including reverting to the pre-9 behavior: - Entity<Blog>().IncludeDiscriminatorInJsonId(); - Entity<Blog>().IncludeRootDiscriminatorInJsonId(); - Entity<Blog>().AlwaysCreateShadowIdProperty(); Note that this change requires regeneration of the Northwind database.
Motivation
Currently we have a lot of rules that determine which properties get configured as keys, partition keys, alternate keys, discriminators, and do on. The intention here is to create a model that will fall into the pit-of-success for use with Cosmos. This works to some extent, but the problem is that it becomes very hard to follow what is actually happening, or why. This means that, for example, that it is difficult to know which properties form a relatively simple concept such as the JSON
id
property. And without knowing the definition of theid
, everything else becomes confusing.Proposal
Remove a lot of the magic from this area to create conventions that are easy to understand, while allowing additional configuration to be done explicitly, also in a non-magical way.
Principle
Based on discussions with the Cosmos folks, we will use the following principle:
Id
discovered by convention should map 1:1 to the JSON id property, unless the developer explicitly configures something different.Notes:
Discriminators
id
property will not have a discriminator added so as to keep it an easy-to-understand 1:1 mappingNote that partition keys will still be added to the EF primary key definition.
id
id
. If this part is calledId
then this is stillId
toid
mapping.The text was updated successfully, but these errors were encountered: