如何撤消上一次的Add-Migration命令? [英] How do I undo the last Add-Migration command?

查看:2104
本文介绍了如何撤消上一次的Add-Migration命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Add-Migration 命令创建了迁移,但是我想更改迁移的名称。如何撤销迁移命令,以便我可以使用新的名称重新生成?

I have created a migration using the Add-Migration command, but I'd like to change the name of that migration. How can I undo the migration command, so that I can regenerate it using the new desired name?

这只是删除生成的文件的问题,或者这可能是一个坏主意?

Is it just a matter of deleting the generated files, or this could be a bad idea?

推荐答案

如果您没有使用更新数据库你可以删除它。如果您已经运行更新,然后使用 Update-Database -TargetMigrationNameOfPreviousMigration,然后将其删除。

If you haven't used Update-Database you can just delete it. If you've run the update then roll it back using Update-Database -TargetMigration "NameOfPreviousMigration", then delete it.

参考:

http ://elegantcode.com/2012/04/12/entity-framework-migrations-tips/

这篇关于如何撤消上一次的Add-Migration命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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