MVC 脚手架不支持 Entity Framework 6 或更高版本 [英] MVC scaffolding does not support Entity Framework 6 or later

查看:26
本文介绍了MVC 脚手架不支持 Entity Framework 6 或更高版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚升级到 Entity Framework 6 来看看.我正在使用 MVC4.

Just upgraded to Entity Framework 6 to take a look. I'm using MVC4.

但我在尝试从模型和上下文中创建控制器时收到此消息.

But i recieve this message when trying to make a controller from a model and context.

MVC 脚手架不支持 Entity Framework 6 或更高版本

MVC scaffolding does not support Entity Framework 6 or later

推荐答案

认为这可以使用一些扩展 :) 如上所述 ASP.NET MVC 4 脚手架不支持 EF6 或更高版本.这意味着必须安装与 MVC 4 兼容的旧版 EF.为此:

Thought this could use some expanding :) As mentioned above ASP.NET MVC 4 scaffolding does not support EF6 or higher. This means that an older EF, compatible with MVC 4 will have to be installed. To do this:

  1. 打开包管理器控制台:
    • 选择工具 -> 库包管理器 -> 包管理器控制台

在包管理器控制台中,通过执行以下命令卸载当前的 EF 包:

In the Package Manager Console, uninstall the current EF package by executing the following command:

UnInstall-Package EntityFramework -Version <版本号>

*其中 是当前安装的 EF 的版本号.
*注意:要了解安装的 EF 版本,请在包管理器控制台中运行以下命令:

*Where <version number> is the version number of the EF currently installed.
*NOTE: to find out what EF version is installed, run the following command in the Package Manager Console:

Get-Package EntityFramework

为避免潜在的元数据问题,需要删除 Web.config 文件中的提供程序条目:

To avoid potential metadata problems the providers entry in the Web.config file will need to be removed:

  • 打开项目目录下的 Web.config 文件.
  • 删除以下行:

  • Open the Web.config file in the project directory.
  • Delete the following lines:

<代码><提供者><provider invariantName=System.Data.SqlClient 类型=System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer/></providers>

现在,在包管理器控制台中执行以下命令安装Entity Framework 5.0.0:

Now, in the Package Manager Console Execute the following command to install Entity Framework 5.0.0:

Install-Package EntityFramework -Version 5.0.0

这篇关于MVC 脚手架不支持 Entity Framework 6 或更高版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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