You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a unique key to be created in the container the EF model must have an alternate key on an entity type that includes the partition key and all entity types sharing the container must have the same key.
The text was updated successfully, but these errors were encountered:
Will this feature also cover having the partition key be part of the lookup in DbSet<T>.Find(...)? I mean without specifically adding the partition key to be part of the complex key.
To be explicit:
publicclassMyModel{publicstringId{get;set;}publicstringPartitionKey{get;set;}}publicclassMyDbContext:DbContext{publicDbSet<MyModel> MyModels {get;set;}protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder){
modelBuilder.Entity<MyModel>().HasPartitionKey(x => x.PartitionKey).HasKey(x => x.Id);}}// Find model:MyDbContextdbContext;MyModelmodel= dbContext.MyModels.Find("partitionKeyValue","idValue");// not two separate values are passed in, but the "key" only has 1 value.
In cosmosdb, it would be preferable the PartitionKey is not part of the Id, as I believe cosmosdb would allow the same id under different partition keys already.
https://docs.microsoft.com/en-us/azure/cosmos-db/unique-keys
For a unique key to be created in the container the EF model must have an alternate key on an entity type that includes the partition key and all entity types sharing the container must have the same key.
The text was updated successfully, but these errors were encountered: