加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net-4.0 – 为什么我在一个新的MVC4项目中收到编译错误?

发布时间:2020-12-15 23:19:42 所属栏目:asp.Net 来源:网络整理
导读:我一直没有找到答案,一直在上网冲浪互联网,所以我希望也许你可以帮助我这个. 当使用Visual Studio 2012时,我创建一个新的MVC4 Web应用程序项目并获得一些编译错误. 这是我的问题: 我使用Visual Studio 2012创建一个新的MVC4 Web应用程序,我选择Internet应用
我一直没有找到答案,一直在上网冲浪互联网,所以我希望也许你可以帮助我这个.

当使用Visual Studio 2012时,我创建一个新的MVC4 Web应用程序项目并获得一些编译错误.

这是我的问题:

>我使用Visual Studio 2012创建一个新的MVC4 Web应用程序,我选择Internet应用程序并将其设置为使用RAZOR Engine.
>我去应用程序属性,在应用程序选项卡下,将目标框架从.NET Framework 4.5更改为.NET Framework 4.
>构建会产生以下错误:

Error 1 The type name ‘TableAttribute’ could not be found. This type has been forwarded to assembly ‘System.ComponentModel.DataAnnotations,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35’. Consider adding a reference to that assembly. c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 21 6 MvcApplication1

Error 2 The type or namespace name ‘Table’ could not be found (are you missing a using directive or an assembly reference?) c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 21 6 MvcApplication1

Error 3 The type or namespace name ‘DatabaseGeneratedAttributeAttribute’ could not be found (are you missing a using directive or an assembly reference?) c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 25 10 MvcApplication1

Error 4 The type name ‘DatabaseGeneratedAttribute’ could not be found. This type has been forwarded to assembly ‘System.ComponentModel.DataAnnotations,PublicKeyToken=31bf3856ad364e35’. Consider adding a reference to that assembly. c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 25 10 MvcApplication1

Error 5 The type or namespace name ‘CompareAttribute’ could not be found (are you missing a using directive or an assembly reference?) c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 54 10 MvcApplication1

Error 6 The type or namespace name ‘Compare’ could not be found (are you missing a using directive or an assembly reference?) c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 54 10 MvcApplication1

Error 7 The type or namespace name ‘CompareAttribute’ could not be found (are you missing a using directive or an assembly reference?) c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 87 10 MvcApplication1

Error 8 The type or namespace name ‘Compare’ could not be found (are you missing a using directive or an assembly reference?) c:userssaaddocumentsvisual studio 2012ProjectsMvcApplication1MvcApplication1ModelsAccountModels.cs 87 10 MvcApplication1

解决方法

简单地重新安装EntityFramework:

>转到包管理器控制台
>卸载 – 包实体框架
>安装包实体框架

那就是错误应该消失!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读