简体   繁体   English

所有项目的行为异常实体框架和模型生成

[英]Strange behavior with all projects Entity Framework and Model Generation

I am having some really strange behavior. 我有一些非常奇怪的行为。 Maybe I am missing something. 也许我缺少了一些东西。 The last thing I can remember doing before this error occured was installing VS 2012 RC1. 在发生此错误之前,我记得的最后一件事是安装VS 2012 RC1。 Tried removing Entity from my project and adding an older version. 尝试从我的项目中删除Entity并添加旧版本。 Also tried a brand new project from scratch with no avail. 还从头开始尝试了一个全新的项目,但无济于事。 Big problem now is that when I deploy just the project dll, it gives the same error on production as developing locally. 现在的大问题是,当我仅部署项目dll时,它在生产上会产生与本地开发相同的错误。 So I am pretty sure it is not tied to my working environment or something I installed. 因此,我很确定它与我的工作环境或安装的东西无关。 Anyway here are the errors generated from Entity and I cannot find any solutions. 无论如何,这是从Entity生成的错误,我找不到任何解决方案。 Please can you pass your wisdom as I need to make some changes to production code and cant seem to get around the error below. 请您通过我的智慧,因为我需要对生产代码进行一些更改,并且似乎无法解决以下错误。

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.

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM