将项目从 .NET 4.0 升级到 .NET 4.5 后失败 =>找不到类型或命名空间名称“MaxLength"/“Column" [英] Failure after upgrading project from .NET 4.0 to .NET 4.5 => the type or namespace name 'MaxLength'/'Column' could not be found

查看:16
本文介绍了将项目从 .NET 4.0 升级到 .NET 4.5 后失败 =>找不到类型或命名空间名称“MaxLength"/“Column"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个面向 .Net 4.0 和实体框架 4.3.1 的工作网站.安装 .Net 4.5(使用 Visual Studio Express 2012)后,我可以在 Visual Web Developer Express 2010 上编译网站,但是当我尝试导航到

I have a working website targeting .Net 4.0 and entity framework 4.3.1. After installing .Net 4.5 ( with Visual Studio Express 2012 ) I can compile the website on Visual Web Developer Express 2010 but when i try to navigate to

http://localhost/ 

我收到此错误:

CS0246找不到类型或命名空间名称‘MaxLength’"

CS0246 "The type or namespace name 'MaxLength' could not be found" on

[Column("titulo"), Required(), MaxLength(150)]
Línea 13:         public string Titulo { get; set; }

我有这个 using 语句:

I have this using statement:

using System.ComponentModel.DataAnnotations;

IIS 上的应用程序池是为 .Net 4.0 配置的.

The application pool on IIS is configured for .Net 4.0.

我尝试将实体框架更新到 4.4(来自 Nuget)并添加了 using 语句:

I tried updating Entity framework to 4.4 ( from Nuget ) and added this using statement:

using System.ComponentModel.DataAnnotations.Schema;

但是错误是:

CS0246找不到类型或命名空间名称‘列’"

CS0246 "The type or namespace name 'Column' could not be found"

有什么解决问题的建议吗?

Any suggestion to solve the problem?

谢谢.

推荐答案

要完成这项工作,您必须执行以下操作:

To make this work you have to do the following:

  1. 打开 NuGet 包管理器并在 Installed packages 选项卡中找到实体框架包.卸载它.

  1. Open NuGet package manager and find in the Installed packages tab the Entity Framework package. Uninstall it.

现在转到 Online 选项卡并搜索实体框架.打安装.现在您的项目应该引用正确版本的 EF那是 5.0 而不是 4.4.0(我在安装之前的版本这个新版本).

Now Go to the Online tab and search for Entity Framework. Hit install. Now your project should reference the correct version of EF that is 5.0 instead of 4.4.0 (the version I had before intalling this new version).

希望有帮助.

有关更多信息,请查看此处:http://forums.asp.net/t/1779042.aspx/1

For more info, take a look here: http://forums.asp.net/t/1779042.aspx/1

这篇关于将项目从 .NET 4.0 升级到 .NET 4.5 后失败 =>找不到类型或命名空间名称“MaxLength"/“Column"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆