Reputation: 921
I'm starting with EF 4.1 code first and I was wondering if somebody out there can help me understand the best way to map this scenario:
I have a class Address:
public class Address
{
public int Id { get; set; }
public string Line1 { get; set; }
public string Line2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
}
And I have two other classes who has addresses:
A) Company has Office Address (required) and Mailing Address
A) Person has Home Address (required), Work Address and "Other Address"
The same scenario also happens with phone numbers. I really appreciate any help on this. Thanks in advance.
Upvotes: 1
Views: 134
Reputation: 107237
I would definitely avoid the "Table per Hierarchy" kind of modelling (i.e. where you embed address directly into Company and Person)
Meaning Addresses are normalised out of your entities and stored separately (so TPC)
You could then either
OR possibly overkill, but an even more flexible model would be
Have a look at these posts here and here for other ideas on how address problems have been tackled.
Upvotes: 1