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
, how could I achieve the samer result where I specify "PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase" for the CosmosDB connection which the EF Core context will use?
EF actually doesn't use the names provided by the serializer. You can specify the desired name during model building: b.Property(p => p.Name).ToJsonProperty("name")
And similarly for embedded entities:
b.OwnsOne(
o => o.ShippingAddress,
sa =>
{
sa.ToJsonProperty("address");
sa.Property(p => p.Street).ToJsonProperty("shipsToStreet");
sa.Property(p => p.City).ToJsonProperty("shipsToCity");
});
You can also use the Metadata property to iterate over all the properties in the model.
EF actually doesn't use the names provided by the serializer. You can specify the desired name during model building: b.Property(p => p.Name).ToJsonProperty("name")
And similarly for embedded entities:
b.OwnsOne(
o => o.ShippingAddress,
sa =>
{
sa.ToJsonProperty("address");
sa.Property(p => p.Street).ToJsonProperty("shipsToStreet");
sa.Property(p => p.City).ToJsonProperty("shipsToCity");
});
You can also use the Metadata property to iterate over all the properties in the model.
How to mention IgnoreNullValues = true in UseCosmos options?
Ask a question
When instantiating a CosmosClient directly, I can do something like:
which allows me to specify the desired SerializerOptions (specifically the PropertyNamingPolicy).
But when I'm leveraging EF Core with UseCosmosDb similar to:
, how could I achieve the samer result where I specify "PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase" for the CosmosDB connection which the EF Core context will use?
Include provider and version information
EF Core version: 6.0.6
Database provider: (e.g. Microsoft.EntityFrameworkCore.Cosmos)
Target framework: (e.g. .NET 6.0)
Operating system:
IDE: (e.g. Visual Studio 2022 17.2.4)
The text was updated successfully, but these errors were encountered: