The mapping details window that displays the mappings between an entity and database table(s) is pretty straightforward.
When you join two related tables in a Table Per Hierarchy inheritance things can get a little confusing when it comes to the mappings for inherited properties.
But did you know that the Mapping Details window uses the Properties window to help?
Here are two entities in a TPH hierarchy.
Customer inherits Contact. Customer maps to a Customers table which uses “ContactID” as its primary key. It entity no longer has its own ContactID property though because it inherits ContactID from the Contact entity.
Here is the Mapping Details window for the Customer entity.
The column on the left displays the database columns while those on the right show which entity property the column is mapped to.
Before I created the hierarchy, Customers.ContactID mapped to a ContactID property in the Customer entity. But that’s gone now. Might be a bit confusing because it says ContactID there still.
If you have the properties window open though it will show you the properties of whatever column or property you have selected.
Click the ContactID in the Value/Property table and you can see that it’s mapping to the Contact.ContactID property, as it should since Customer.ContactID no longer exists.
You can also see properties of selected database columns which are read In the store schema. Here, I have selected the ContactID column on the left. The property window shows that it is from the ContactID column defined in the BreakAwayModel.Store.Customers which is the schema representation of what’s in the database.
And now for the footnote. I just discovered this today in VS2010 but before I blogged about this great new feature (really it can be helpful if you need it) I opened up VS2008 and discovered its been there all along. 🙂 I just happened to have the Properties window open today when clicking around in the mapping and noticed something changing.
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!