Error 3004: Problem in mapping fragment starting at line

Steve Kershaw picture Steve Kershaw · May 19, 2011 · Viewed 66.2k times · Source

I have this error when I build my Web Service:

Error 3004: Problem in mapping fragment starting at line 323: No mapping specified for properties JE_TRN_HS.JE_HDR_HSJE_HDR_KEY. Entity is type [TESTCPModel.JE_TRN_HS

This is what happend. I created this Entity Data Model from an existing database. I added 2 tables and rebuilt the Web Service. The build was successfull.

THEN I added an Association between the two tables. When I tried to rebuild it failed with the error message displayed above!

Now here's the kicker! I deleted the newly added Association and rebuilt. The build failed with the same error message!? The only way I can get rid of this error is if I delete the second table, rebuild and re-add the second table??

I've looked EVERYWHERE for the solution to this problem! Thanks Steve

Answer

Carlos picture Carlos · Sep 20, 2011

In my case am not allowed to modify existing tables but I discovered that when you add a new table with "Include foreign key columns in the model" checked in EF4 and the table doesn't contain any foreign key relationships then you try to add a association it will trigger this error.

Defining Constraints in an EF4 model that don’t exist in the database


In case the linked article disappears, The solution is:

You need to open the properties window of the association and then click on the Referential Constraint ellipses to get to the ref constraint dialog. Then select the correct field for the 'Dependent Property' setting.