实体框架中的错误3027 [英] Error 3027 in entity framework

查看:128
本文介绍了实体框架中的错误3027的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Entity Framework并在我的代码中收到以下错误,并想知道如何继续:



I am just getting started with Entity Framework and getting the following error in my code and would like to know how to proceed:

Error   29  Error 3027: No mapping specified for the following EntitySet/AssociationSet - COUNTRies, PRHs.  C:\svn_workspace\FoxTool\Source\Fox.DataAccessService\FoxEFModel.edmx   457 9   Fox.DataAccessService





我现在没有设置任何关系(至少我看不到)。



I do not right now have any relationships set up (at least I see none).

推荐答案

有时,如果对EDMx文件进行任何更改,或者更改数据库列并进行更新,则EDMx文件的映射xml表示会出现损坏,并且您收到此错误。只需单击control + A删除EDMx文件中的所有对象并再次添加数据库,或者您可以在XML视图中打开EDmx文件并尝试查找未映射的协议并将其删除
Sometimes if you make any changes to the EDMx file or if you change a database column and do an update the mapping xml representation for the EDMx file gets corrupte and you receive this error. just click control + A delete all objects in the EDMx file and add the database again, or you can open the EDmx file in the XML view and try to find the unmapped assosiacition and delete it


转到解决方案资源管理器,单击搜索按钮,选中在文件内容中搜索和搜索外部文件,键入映射无法识别的实体名称。删除与问题相关的所有文件。这些可能会以相同的缺失实体命名。请勿删除文件中包含Context类名的任何文件,特别是如果它们的扩展名为.cs或.tt。在Context .cs文件中,删除引用缺失实体的所有代码行。它们将如下所示:



Go to Solution Explorer, click the Search button, leave checked both "Search within file content" and "Search External Files", type the entities name your mapping isn't recognizing. Delete all files RELATED to the problem. Those will probably be named after the same missing entity. DO NOT delete any file with your Context Class name on the file, specially if their extensions are .cs or .tt. In the Context .cs file, remove all lines of codes referencing the missing entity. They will look like this:

public virtual DbSet< COUNTRies> COUNTRies { get; set; }







此错误对于从数据库中删除的表是常见的。您在数据库中删除了一个表,或者您只是更改了EF Mapped数据库的web.config.connectionStrings,指向一个新的,而不是您用于生成原始映射的那个,并且在这个新的数据库中这些实体具有3027错误不存在。




This error is common to tables deleted from the database. You drop a table in the database, or you just change your web.config.connectionStrings for the EF Mapped database, pointing to a new, not the one you used to generate the original mappings and in this new db these entities with the 3027 error aren't present.


这篇关于实体框架中的错误3027的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆