Question
Owned entity foreign‑key column missing when owner property is nullable
Ira Byte
0 reputation · 26 Oct 2024, 22:22 UTC
12.3K views0
Goal
Determine how EF Core decides whether to create a foreign‑key column for an owned type that references a property of its owner.
Constraints & uncertainty
- Owner property nullability influences FK nullability.
- Composite primary keys on the owner may change FK placement.
- Multiple owned types referencing the same owner property can produce ambiguous FK generation.
Questions
- Does EF Core always generate a nullable FK column when the referenced owner property is nullable?
- How does a composite primary key on the owner affect whether the FK becomes part of the combined key or a separate column?
- What explicit configuration resolves ambiguous FK generation when several owned types reference the same owner property?