14

I am using EntityFramework 6 and I used Update Model from Database after inserting table in the database, I got above error.Please state how to overcome this problem.

Ajay2707
  • 5,690
  • 6
  • 40
  • 58
user5014787
  • 191
  • 1
  • 1
  • 10
  • 1
    Make sure the table/stored procedure/foreign key, for which the error is thrown, also exists in the database from which you are updating the model. – kelsier Jun 17 '15 at 05:32
  • Dear it exists in the database – user5014787 Jun 17 '15 at 05:34
  • possible duplicate of [Why am I getting this error: No mapping specified for the following EntitySet/AssociationSet - Entity1?](http://stackoverflow.com/questions/5667355/why-am-i-getting-this-error-no-mapping-specified-for-the-following-entityset-as) – kelsier Jun 17 '15 at 05:51
  • Please add details re the table and its associations. – Gert Arnold Jun 17 '15 at 08:26

8 Answers8

17

Open the edmx file on notepad, find the unmapping association and remove it. It should work.

itavq
  • 135
  • 9
Junior
  • 171
  • 2
  • 5
  • strangely this worked for me, why was the sysdiagrams included in the first place? I did not add it... Not a pretty but effective solution :) – JohanLarsson Apr 18 '17 at 10:22
6

Not too satisfying, but I solved it by removing and re-adding the model:

  1. Right-click on edmx-diagram and select "Model browser"
  2. Remove the entity type that's giving the problems
  3. Save (just to be sure, regenerates files)
  4. Add model from databasetable again and save.

The warning was gone afterwards.

Ajay2707
  • 5,690
  • 6
  • 40
  • 58
Laurens B
  • 61
  • 1
  • 2
3

I got the same error and found that the foreign key in the table I had added was not of the same type as in the referenced table.

Rune Jeppesen
  • 1,121
  • 13
  • 22
2

Here how I fix this:

  1. Remove all the entities in your Diagram in your edmx file.
  2. Rebuild your project if this edmx file is part of a project in your solution.
  3. Rebuild your solution.

I am not sure why this happens but on my part, it consistently triggers this error when I update my database, and I didn't update my edmx file.

Willy David Jr
  • 8,604
  • 6
  • 46
  • 57
2

Try removing entity (table) from EDMX then run update to add that table again.

ForcedFakeLaugh
  • 567
  • 1
  • 9
  • 20
0

Sometimes there is the problem in Entity Framework when we update tables then other objects like SP's automatically refreshed. Please make sure this was not happened in your case. Other thing you can try - replace model.tt file with new one, to achieve this,

  1. Right click anywhere in your edmx file.
  2. Select "Add code generation item".
  3. Choose "EF 6.x EntityObject Generator".
  4. Change name from "Model2.tt" to "Model1.tt"(if your old model file name was model1.tt).
  5. Click Add.
Dev D
  • 225
  • 1
  • 13
0

Remove and then re-add the tables to the EDMX to fix the mapping issue.

0

It may happen if you've tried many times to update your model from the database, and there are conflicting changes. If you're using git, discard the changes in the edmx file, or roll back to a previous version. Then right click on the edmx file in Visual Studio > Update model from database Select the new tables/views you want to include, otherwise it will simply refresh > Finish

Raphael Pinel
  • 2,352
  • 24
  • 26