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

前端之家收集整理的这篇文章主要介绍了.net-4.0 – 为什么我在一个新的MVC4项目中收到编译错误?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直没有找到答案,一直在上网冲浪互联网,所以我希望也许你可以帮助我这个.

当使用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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.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:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 87 10 MvcApplication1

解决方法

简单地重新安装EntityFramework:

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

那就是错误应该消失!

原文链接:https://www.f2er.com/aspnet/250223.html

猜你在找的asp.Net相关文章