Click here to Skip to main content
14,106,748 members
Rate this:
 
Please Sign up or sign in to vote.
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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!
   
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Deleted association from the XML file since it was not being deleted/updated automatically when the association was deleted/updated in the database.
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

remove the particular table from model browser..in both model.store ande entity .
After that add again the same table..it will work
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190518.1 | Last Updated 2 Aug 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100