Mapping Fragments Entity Framework Error
Asked Answered
S

2

5

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.

Sundberg answered 23/10, 2014 at 2:54 Comment(1)
Looks like you have keys in your model but the keys don't exist on the database.Hbeam
C
6

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.

Chisholm answered 23/10, 2014 at 9:9 Comment(0)
E
3

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!

Eurhythmic answered 23/10, 2014 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.