.net 如何将实体框架从 6 降级到 5?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20282678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:33:56  来源:igfitidea点击:

How to downgrade Entity framework from 6 to 5?

.netentity-framework

提问by ca9163d9

I'm creating a Asp.Net MVC project using VS2013 and added hottowel (2.0.1) using nuget. However, the breeze doesn't work with Entity Framework 6.

我正在使用 VS2013 创建一个 Asp.Net MVC 项目并使用 nuget 添加 hottowel (2.0.1)。但是,轻而易举不适用于 Entity Framework 6。

How to downgrade the Entity Framework 6 of the created project to EF5?

如何将创建的项目的 Entity Framework 6 降级到 EF5?

回答by Not loved

in the nuget package console for your project (select it in the dropdown) type:

在项目的 nuget 包控制台中(在下拉列表中选择它)键入:

Uninstall-package EntityFramework
Install-Package EntityFramework -version 5.0.0

回答by Default

Entity Framework also moves the __MigrationHistorytable from System Tables to user tables. When I tried to run my application after rollback it wouldn't work, so I had to move the __MigrationHistoryback to the system tables with:

实体框架还将__MigrationHistory表从系统表移动到用户表。当我在回滚后尝试运行我的应用程序时它不起作用,所以我不得不将它移__MigrationHistory回系统表:

EXEC sys.sp_MS_marksystemobject __MigrationHistory;

When I did upgrade to EntityFramework 6 I had to add an empty migration (unfortunately I do not remember the reason, but I guess it complained about updating the database or similar). I also had to remove that empty migration. Since this was a completely empty migration I guess this is safe to do, I do not know about migrations that actually change the database. However, they might not complain when running the program.

当我升级到 EntityFramework 6 时,我不得不添加一个空的迁移(不幸的是我不记得原因,但我猜它抱怨更新数据库或类似的东西)。我还必须删除那个空迁移。由于这是一个完全空的迁移,我想这是安全的,我不知道实际更改数据库的迁移。但是,他们在运行程序时可能不会抱怨。

delete from dbo.__MigrationHistory where MigrationId = 'myEmptyMigration';

Then I deleted the empty migrationfile from my project which resolved my problems.

然后我从我的项目中删除了空的迁移文件,这解决了我的问题。

回答by Jay Traband

The Breeze packages marked with "(obsolete)" are intended for use with EF5 and WebApi. The 'current' packages ( those not marked with obsolete) are all intended for WebApi2 and EF6. There is no option currently to mix and match EF5 with WebApi2. If this is important please add this to the Breeze User Voice

标有“(过时)”的 Breeze 软件包旨在与 EF5 和 WebApi 一起使用。“当前”包(未标记为过时的包)均适用于 WebApi2 和 EF6。目前没有将 EF5 与 WebApi2 混合搭配的选项。如果这很重要,请将其添加到Breeze 用户语音中

回答by Kezza

I realize this is an old post with an Answer already but thought I'd add this little nugget.

我意识到这是一篇带有答案的旧帖子,但我想我会添加这个小金块。

If you have many projects using Entity Framework and want to downgrade all of them, first change one of the projects manually, then refresh the package description page and you will get Consolidate as an Action. Select this, then select version 5.0.0 and this will let you downgrade all projects to 5.0.0

如果你有很多使用 Entity Framework 的项目,并且想要将它们全部降级,请先手动更改其中一个项目,然后刷新包描述页面,您将获得 Consolidate as an Action。选择此项,然后选择版本 5.0.0,这将使您将所有项目降级到 5.0.0

回答by Ghebrehiywet

on Package Manager Consolewrite

包管理器控制台写入

PM> Uninstall-package EntityFramework

PM> 卸载包 EntityFramework

PM> Install-Package EntityFramework-version 5.0.0

PM> 安装包EntityFramework-version5.0.0