Elfocrash / Cosmonaut

🌐 A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
342 stars 44 forks source link

Unable to resolve iD for entity of type Tenant) #18

Closed levalencia closed 5 years ago

levalencia commented 5 years ago

Can you help me here? great library btw!

https://stackoverflow.com/questions/51468975/adding-a-cosmosdb-entity-unable-to-resolve-id-for-entity-of-type-tenant

Elfocrash commented 5 years ago

Hello and thanks for using Cosmonaut.

As the Github Readme page stages in the Restrictions section

Because of the way the internal id property of Cosmosdb works, there is a mandatory restriction made. You cannot have a property named Id or a property with the attribute [JsonProperty("id")] without it being a string. A cosmos id need to exist somehow on your entity model. For that reason if it isn't part of your entity you can just implement the ICosmosEntity interface or extend the CosmosEntity class.

The recommended fix in your case would be to decrate the TenantId with the [JsonProperty("id")] attribute.

If you like the library make sure you give it a star. It really helps.