I have a Post entity that has an Author as a embedded entity. I would like the Author Id to be my partition key. But when I try to do this through fluent api I get the error below:
Im try this:
builder.HasPartitionKey(x => x.Author.UserId);
and i get this:
System.ArgumentException: 'The expression 'x => x.Author.UserId' is not a valid member access expression. The expression should represent a simple property or field access: 't => t.MyProperty'. Arg_ParamName_Name'
I think the right way would be:
builder.OwnsOne(x => x.Author, sa =>
{
sa.Property(x => x.UserId).HasConversion(new GuidToStringConverter());
sa.HasPartitionKey(x => x.UserId);
});
but its not possilble.
How can I solve this problem?
EF Core version:
Database provider: (e.g. Microsoft.EntityFrameworkCore.Cosmos 5.0.9)
Target framework: (e.g. .NET 5.0)
Operating system:
IDE: (e.g. Visual Studio 2019 16.10.0)
I have a Post entity that has an Author as a embedded entity. I would like the Author Id to be my partition key. But when I try to do this through fluent api I get the error below:
Im try this:
and i get this:
I think the right way would be:
but its not possilble.
How can I solve this problem?
EF Core version:
Database provider: (e.g. Microsoft.EntityFrameworkCore.Cosmos 5.0.9)
Target framework: (e.g. .NET 5.0)
Operating system:
IDE: (e.g. Visual Studio 2019 16.10.0)