EF4 and multiple abstract levels

Posted by Cedric on Stack Overflow See other posts from Stack Overflow or by Cedric
Published on 2012-10-03T07:45:13Z Indexed on 2012/10/05 9:37 UTC
Read the original article Hit count: 347

I need to use inheritance with EF4 and the TPH model created from DB.
I created a new projet to test simples classes. There is my class model:

enter image description here

There is my table in SQL SERVER 2008 :

VEHICLE 
  ID : int PK
  Owner : varchar(50)
  Consumption : float
  FirstCirculationDate : date
  Type : varchar(50)
  Discriminator : varchar(10)

I added a condition in my EDMX on the Discriminator field to differentiate the Scooter, Car, Motorbike and Bike entities.

MotorizedVehicle and Vehicle are Abstract.

But when I compile, this error appears :

Error 3032: Problem in mapping fragments starting at lines 78, 85:EntityTypes EF4InheritanceModel.Scooter, EF4InheritanceModel.Motorbike, EF4InheritanceModel.Car, EF4InheritanceModel.Bike are being mapped to the same rows in table Vehicle. Mapping conditions can be used to distinguish the rows that these types are mapped to.

Edit :
To Ladislav :
I try it and error change to become it for all of my entities :

Error 3034: Problem in mapping fragments starting at lines 72, 86:An entity is mapped to > different rows within the same table. Ensure these two mapping fragments do not map two > groups of entities with overlapping keys to two distinct groups of rows.

To Henk (with Ladislay suggestion) :
There are all of mappings details : enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

What's wrong ?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about entity-framework