Entity Framework – Inheritance/Association – including Troubleshooting and comment on verbose SQL

See this video on Model Table Per Type


  1. Update Model from Database – Add Table
  2. Right-click Entity Add Inheritance
  3. Error 11009: Property ‘<>’ is not mapped
  4. Right-click Entity > Table Mapping > re map missing
  5. Running transformation: A member named ID cannot be defined in class DerivedClass. It is defined in ancestor class ParentClass.
  6. Delete it from DerivedClass

Error 3027: No mapping specified for the following EntitySet/AssociationSet – TableATableB

Error 11008: Association TableATableB is not mapped
EF is not expecting both a Foreign Key relationship and an association, see note at top of: http://msdn.microsoft.com/en-us/library/bb738488.aspx
Delete the association

Existing queries may then break as the Entity type no longer exists. So in my case Products is base type PadMain inherits from this. Used to have PadMains now PadMain EntityName is Products, so query on PadMains needs to change. From/To:

From b In context.PadMains
From b in context.Products1.OfType(Of PadMain)()

However if PadMain has subtypes then the SQL generated is verbose. If table is separated out in SQL then you just want the base table. If a field will appear in multiple related child tables then you will get duplications. In this scenario this is a major disadvantage of Entity Framework. Hopefully it will be fixed in future. For now I have removed my inheritance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: