The 0..1 model is usually an is-a relation. This maps to Inheritance in C#. In C# you cannot create classes that inherit from multiple other classes (only through interfaces)
Your model is purely modelled as a Relational Database, but it doesn't map to an object structure that doesn't have multiple inheritance. Define a model in C# that works (using inheritance and relations), then generate a Datamodel for it, since in this case C# is the limiting factor.
Remember that you can use Inheritance:
Customer
<--is-a- Corporate Customer --has-a-- Organization --has-many-|
<--is-a- Natural Customer --has-a-- Person <--is-a- Employee
In this case you won't be able to cast a Customer
directly to a person or an organization, but you can get to the record that is linked to this class, which feels natural to me. But an Employee is always a Person (which makes sense).
If you want to you can inherit both Organization
and Person
from LegalEntity
. Either in the model above (retaining the Natural/Corporate Customer
),
Customer<T:LegalEntity> -----------has-a--------------- LegalEntity
^ ^
|--is-a- Customer<Organization> (--has-a--) Organization -is-a-| --has-many
L--is-a- Natural<Person> (--has-a--) Person -------is-a-| |
^ |
L--is-a- Employee -------|
But you can also simplify the model further in that case:
Customer
|--has-a LegalEntity <---is-a-- Organization --has-many-|
L-is-a-- Person <--is-a- Employee
Or you can use Person as the basis, but that leads to a more ugly model:
Person
<- Employee ---- Organization <- Corporate Customer
<- Natural Customer ----| |
| |
L------------------------------->> ICustomer
In which case your Person
can be either an Employee
or a Natural Customer
(but not both), plus you can't create a list of Customer
that contains both Natural Customer
and Corporate Customers
, except through Interfaces, but Entity Framework doesn't always understand those. This model feels awkward, but seems closer to your current model.
The full fidelity model you want can't be built using .NET or Entity Framework.