views:

41

answers:

1

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

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

alt text

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

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

+1  A: 

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.

Craig Stuntz
I have already done it without the tutorial. I took me 2 more days to figure it out as the designer is not really intuitive. Anyway, nobody on this site seemed to care to explain me those 3-4 easy steps how to do it.
drasto