Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping Fragments Entity Framework Error

I'm developing an ASP.NET MVC4 application (database first approach), right now I updated the model from database and then after that I got this error:

Problem in mapping fragments starting at line 1106:Potential runtime violation of table Trn_BenchProficiency's keys (Trn_BenchProficiency.BenchNumber): Columns (Trn_BenchProficiency.BenchNumber) are mapped to EntitySet Trn_BenchProficiency's properties (Trn_BenchProficiency.BenchNumber) on the conceptual side but they do not form the EntitySet's key properties (Trn_BenchProficiency.AssessedDate, Trn_BenchProficiency.BenchNumber, Trn_BenchProficiency.Proficiency, Trn_BenchProficiency.SkillAllignmentID, Trn_BenchProficiency.SkillID).

When I double click the error visual studio displayed this:

enter image description here

Kindly help me, what is the problem with this? I really cant find the error.

like image 967
Luigi Vibal Avatar asked Oct 23 '14 02:10

Luigi Vibal


2 Answers

Try to delete the tables in edmx diagram and update your diagram then add your tables again. Save and rebuild your solution.

I always encounter that when I have changes in relationship of the tables.

like image 63
Kenneth Avatar answered Oct 22 '22 21:10

Kenneth


Entity framework designer had identified your Trn_BenchProficiency.BenchNumber as a primary column. Changed that setting to false for Trn_BenchProficiency.BenchNumber.

Follow this steps to that:

Go to your .edmx file, right click on the background and select Mapping Details.

Click on the table you need to edit the mappings and the details should appear in your new Mapping Details window.

Hit F4 to bring up the Properties window.

Click on the Value/Property in your Mapping Details to change the Properties displayed, and from your Properties window you can now set the Entity Key value to False.

Hope this helps!

like image 24
jomsk1e Avatar answered Oct 22 '22 22:10

jomsk1e