我刚刚创建了一个新的 MVC 2 应用程序,它同时引用了一个实体模型库和一个服务库,并且在没有运行应用程序的情况下所有编译都很好,但是当我尝试运行它时,我收到以下运行时错误”
Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
我已经仔细检查了 umteen 次(例如 Umpteen*n)并且引用的程序集在所有三个项目中都有引用。如果不是,WTF 会不会出现构建错误?
最佳答案
对于 ASP.NET MVC 4 (.NET4.5) 从
<system.web>
<compilation debug="true" targetFramework="4.0" />
...
到
<system.web>
<compilation debug="true" targetFramework="4.0" >
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
关于asp.net - Entity Framework 和 MVC 应用程序中的奇怪编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3219412/