Error 3027: No mapping specified for the following EntitySet/AssociationSet

Deadly 提交于 2020-02-03 05:31:05

问题


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.


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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




回答6:


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.



回答7:


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



来源:https://stackoverflow.com/questions/30882946/error-3027-no-mapping-specified-for-the-following-entityset-associationset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!