0

我有一些非常奇怪的行为。也许我错过了一些东西。在此错误发生之前我记得做的最后一件事是安装 VS 2012 RC1。尝试从我的项目中删除实体并添加旧版本。还从头开始尝试了一个全新的项目,但无济于事。现在的大问题是,当我只部署项目 dll 时,它会在生产中产生与在本地开发相同的错误。所以我很确定它与我的工作环境或我安装的东西无关。无论如何,这里是从实体生成的错误,我找不到任何解决方案。请您传递您的智慧,因为我需要对生产代码进行一些更改并且似乎无法解决下面的错误。

System.Data.Edm.EdmEntityType: : EntityType 'UrlHelper' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RequestContext' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'HttpContextBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Exception' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Type' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'AssemblyName' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'CultureInfo' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'DateTimeFormatInfo' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'Calendar' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'IdentityReference' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RouteData' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'RouteBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'ControllerContext' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'ControllerBase' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: Name: The specified name is not allowed: '__ConsoleStream'.
System.Data.Edm.EdmEntityType: : EntityType 'Encoding' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntityType: : EntityType 'TextWriter' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntitySet: : The referenced EntitySet �ActionResults� for End �ContentResult_ContentEncoding_Source� could not be found in the containing EntityContainer.
System.Data.Edm.EdmEntitySet: : The referenced EntitySet �ActionResults� for End �JsonResult_ContentEncoding_Source� could not be found in the containing EntityContainer.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �UrlHelpers� is based on type �UrlHelper� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RequestContexts� is based on type �RequestContext� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �HttpContextBases� is based on type �HttpContextBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Exceptions� is based on type �Exception� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Types� is based on type �Type� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �AssemblyNames� is based on type �AssemblyName� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �CultureInfoes� is based on type �CultureInfo� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �DateTimeFormatInfoes� is based on type �DateTimeFormatInfo� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Calendars� is based on type �Calendar� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �IdentityReferences� is based on type �IdentityReference� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RouteDatas� is based on type �RouteData� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �RouteBases� is based on type �RouteBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ControllerContexts� is based on type �ControllerContext� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ControllerBases� is based on type �ControllerBase� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �Encodings� is based on type �Encoding� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �TextWriters� is based on type �TextWriter� that has no keys defined.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet �ActionResults� is based on type �ActionResult� that has no keys defined.
4

1 回答 1

0

So stupid! I created a model inheriting from my controller. So Entity was trying to create a table based on my controller properties. Sometimes the most basic programming mistakes take you the longest to solve.

public class MyClass : Controller

Instead of

public class MyClass
于 2012-06-19T09:17:17.787 回答