Rasto
Rasto

Reputation: 17844

Inheritance of database tables in VS

I want to create Table-Per-Type database table inheritance.

Simply base table RowElement will have 2 children tables. First child table Lyrics will inherit all parents RowElement's columns and will just add one more column. Second child table ChordUse will only many-to-one relationship to table Chord.

This is how my database schema looks like:

alt text http://www.freeimagehosting.net/uploads/ae4d8bd348.jpg

The problem is that when I let the VS create E/R diagram for me it creates this:

alt text http://www.freeimagehosting.net/uploads/774b194451.jpg

So it creates an 1-to-1-0 entity relationship instead of inheritance. I can't get VS to create inheritance relationship mapped correctly to database. Please help me.

After generating E/R diagram from my database I would like to have something like:

alt text http://www.freeimagehosting.net/uploads/e532f09b8a.jpg

Where RowElement is abstract class. Thank you for any help.

Upvotes: 0

Views: 659

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126587

The EF designer (for good reasons, IMHO -- inheritance is overused in OR models) will never infer inheritance. You need to set it up yourself. You are asking for "table per type" inheritance. Follow the walkthrough with the demo model. When you've got that working, you'll be ready to do it with your real model.

Upvotes: 1

Related Questions