so I’d been using CosmosClient to develop my app, but I wanted to implement Domain Events which are not supported with CosmosClient, so I had to switch to EF Core. When using EF Core I can’t get my entities from the db, because of the Id being saved as “id” in cosmos.
I tried to use JsonProperty(“id”), Column(“id”) and also AsNoTracking, but all give the same results. What should I do?
My BaseEntity class:
public abstract class BaseEntity
{
[JsonProperty("id")]
[Column("id")]
public virtual string Id { get; set; } = Guid.NewGuid().ToString();
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? ModifiedAt { get; set; }
}
My ComosDb document:
{
"OrderNumber": "1000000000",
"PatientData": {
...
},
"Results": {
...
},
"Status": 2,
"id": "1000000000",
"CreatedAt": "2024-03-21T17:58:50.432892+01:00",
"ModifiedAt": "2024-03-24T01:24:17.52464Z",
"_rid": "7NA1AKlBYQ8MAAAAAAAAAA==",
"_self": "dbs/7NA1AA==/colls/7NA1AKlBYQ8=/docs/7NA1AKlBYQ8MAAAAAAAAAA==/",
"_etag": ""0000a702-0000-5600-0000-65ff80c10000"",
"_attachments": "attachments/",
"_ts": 1711243457
}
kamildobkowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.