Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 3004: Problem in mapping fragment starting at line [closed]

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

like image 504
Steve Kershaw Avatar asked May 19 '11 19:05

Steve Kershaw


2 Answers

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.

like image 63
Carlos Avatar answered Sep 21 '22 17:09

Carlos


In my case, another developer had deleted the field from the table in the database. Having realised this, removing the table from the entity model and adding it back solved the problem.

like image 38
Graham Laight Avatar answered Sep 24 '22 17:09

Graham Laight