What is an owned entity type in EF Core?
Quick Answer
An owned type is a class that has no identity of its own and belongs to a parent entity — a Money, an Address. Configure with OwnsOne/OwnsMany. By default its columns are stored in the parent's table (table splitting), and it has no DbSet — you always access it through the owner.
An owned type is a class that only makes sense as part of its parent — it has no id of its own. The classic example is an Address or a Money value object. You configure it with OwnsOne, and by default EF puts its columns right in the parent's table with prefixed names. There's no DbSet for it — you only ever get to it through the owning entity, and it's loaded and saved along with the owner. It's EF's built-in support for DDD value objects.
- Models domain-driven-design value objects cleanly:
Orderhas aShippingAddressowned type, columnsShippingAddress_Street,ShippingAddress_Cityin theOrderstable. OwnsManystores the collection in a separate table keyed by the owner.- Owned instances are loaded and saved with the owner automatically — no separate query.
- Limitations: no inheritance, can't be shared by two owners as the same instance, querying by an owned property works but has quirks.