Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi There,

I am faced with a new issue, I have been using entity framework in one of my projects for quite sometime. Today I came across a table in sql that was created by someone who worked on the project a long time ago.

The table had no Primary Key column so I decided to add 1 in, I then updated the EDMX file in my solution but it now keeps throwing up this error:

Must specify mapping for all key properties.

I dropped the table and recreated but this error is not going away at all.

I would really appreciate some help on this.

Thanks.

What I have tried:

Google the issue.

Delete the current EDMX and import a new 1.

Rebuild/Clean the solution.
Posted
Updated 1-Aug-18 20:22pm

First of all, you have to udpate (recreate) .edmx file from schema (database).
How? In the EF Designer[^] - right-click -> Update Model from Database.

In case it won't help, please follow these:
Editing an .edmx File Manually (Entity Framework)[^]
EDM - Must specify mapping for all key properties of entity set[^]

Good luck!
 
Share this answer
 
Comments
Kats2512 16-Apr-18 11:50am    
Yeah right click update model from database. I even deleted the entity/table from the diagram.

Will check the link tomorrow when I get back to work.
Kats2512 17-Apr-18 3:23am    
for some stupid reason I opened the EDMX as xml and found that it was refusing to delete the association. After deleting the xml text the error has gone and the edmx has been updated correctly.

No idea why it does not want to delete automatically.
Deleted association from the XML file since it was not being deleted/updated automatically when the association was deleted/updated in the database.
 
Share this answer
 
remove the particular table from model browser..in both model.store ande entity .
After that add again the same table..it will work
 
Share this answer
 
Comments
Kats2512 2-Aug-18 2:39am    
Read solution 2, I have already found a way around this issue.

I did try your way but that does not work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900