EF Core Many-to-One (Many Owned Entity to Non-owned Entity)
In the context of a multi-tenant application, I want to design an aggregate like so - a root
Customer
has a List<Address>
, Address
being an owned type. A Customer
also references a Tenant
. If I also want Address
to reference a Tenant
, it seems EF Core isn't happy when trying to configure a Tenant
like so:
3 Replies
sounds like you don't want Address to be an owned type
Well, I guess I do? I don't need to access
Address
outside the context of a Customer
.
I don't really need an identifier for Address
. It should have value object semantics.
With it being owned, I can hide the fact that there still is an address_id
being generated in the underlying table (as required by the One-to-Many relationship between Customer
and Address
. Otherwise I'd have to specify AddressId
in Address
?yeah
if EF doesn't support both, then it doesn't support both