“Ambiguity between X and X” for every property after modifying entity model [closed]

大憨熊 提交于 2020-02-23 09:33:49

问题


I'm getting "Ambiguity between 'XYZ.EntityX.PropertyX' and 'XYZ.EntityX.PropertyX'" errors on every reference to properties in my entity model after making a small change to it and attempting to recompile. Both properties are identical in every case. There are also a lot of "The type 'XYZ.EntityX' already contains a definition for 'PropertyX'". Has anyone run into anything like this before?

I recently put the code into source safe, which I'll take a wild guess and say may have something to do with it. Maybe it cant update a file that's not checked out and also isnt prompting about it? I have no idea.

All I did was go into XYZModel.edmx, select a table, add a scalar property (string, 50 chars, nullable) and recompile. Everything worked until then. It also happens when I 'Update model from database'. I'm guessing any change at all to the model will cause it.


回答1:


I had the exact same problem in Visual Studio 2015 but I used TFS instead of Sourcesafe.

First option is to make sure you are connected to your Source Control (Online).

If that doesn't work

  1. Make sure your Visual Studio solution is connected to TFS/Source Control. This issue can occur when your offline mode. Right click on the solution and select Go Online if your offline.
  2. Once your online connected to TFS in Visual Studio right click on the edmx and select Goto Source Control->Undo Pending changes. This will undo all the pending changes for the edmx and the associated generated files.
  3. Delete the changed table from the edmx and add it again.
  4. Build your solution



回答2:


I had this same issue. For some reason when updating my Entity Framework model it had created a second Model.Context.cs file.

This seemed to be because the original one had become disconnected from the model and it had to create a new one. I deleted the original one and it fixed the issue.

These .cs files should be visible in the Solution Explorer by finding the Model.edmx expanding out then finding and expanding out the Context.tt file.




回答3:


I think you move or copy some file to other folder so they appear this error!




回答4:


Just had the same error just now and i found out that i had copied classes to a new folder and not changes their names.

I have a Folder name Group and City, i then copied classes from Group to City when Group and City folders are referenced on the appservice i'm getting errors from.



来源:https://stackoverflow.com/questions/15666646/ambiguity-between-x-and-x-for-every-property-after-modifying-entity-model

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