I have this entity model:
I want to have a Customer
entity, which can be either a Person
or an Organization
, It can't be both.
As of now I came up with a customer entity which points to both organization and person but with a nullable field (meaning Guid?
), which means having a non-mandatory relationship with Person
and Organization
. Something like:
class Customer
{
public Guid ID { get; set; }
public Guid? RelatedPersonID { get; set; }
public Guid? RelatedOrganizationID { get; set; }
public int CustomerStatus { get; set; }
public bool IsVIP { get; set; }
// ... other customer related properties
public virtual Person RelatedPerson { get; set; }
public virtual Organization RelatedOrganization { get; set; }
}
I'm using entity framework 5, codefirst approach and I haven't created the database yet. I was wondering if there's a better model that meets this requirements.