EF迁移:上次应用迁移的回滚? [英] EF Migrations: Rollback last applied migration?

本文介绍了EF迁移:上次应用迁移的回滚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来是一个非常常见的任务,但我找不到一个简单的方法。

This looks like a really common task, but I can't find an easy way to do it.

我想撤消上次应用的迁移。我会预期一个简单的命令,如

I want to undo the last applied migration. I would have expected a simple command, like

PM> Update-Database -TargetMigration:"-1"

相反,我可以想出的是: / p>

Instead, all I can come up with is:

PM> Get-Migrations

Retrieving migrations that have been applied to the target database.
201208012131302_Add-SystemCategory
201207311827468_CategoryIdIsLong
201207232247409_AutomaticMigration
201207211340509_AutomaticMigration
201207200025294_InitialCreate

PM> Update-Database -TargetMigration:"CategoryIdIsLong"

(至少我可以使用名称,跳过时间戳...)

(At least I can use just the name, skipping the timestamp...)

有更简单的方法吗?

推荐答案

在EF 5.0之前,您描述的方法是首选方式。一个解决方案是创建一个自动执行上述步骤的包装器PS脚本。此外,您可以随时为此创建一个功能请求,或者更好地实现它! http://entityframework.codeplex.com/

As of EF 5.0, the approach you describe is the preferred way. One solution would be to create a wrapper PS script that automates the steps above. Additionally, feel free to create a feature request for this, or better yet, take a shot at implementing it! http://entityframework.codeplex.com/

这篇关于EF迁移:上次应用迁移的回滚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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