首先以Entity Framework代码还原数据库 [英] Revert database in Entity Framework code-first

查看:51
本文介绍了首先以Entity Framework代码还原数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在模型中制作了一个,并使用

I made a in my model and updated database using

Add-Migration sdfgfsd
Update-Database

现在我发现我所做的更改是不必要的。

Now I found the change I just made is not necessary.

我想同时还原代码和数据库。

I would like do revert both code and database.

我该怎么做?

推荐答案

是的-很简单。使用

Update-Database -TargetMigration:zzzz

其中 zzzz 是要回滚的迁移之前的迁移名称。

Where zzzz is the name of the migration before the one you want to rollback.

编辑
然后,您需要在zzzz之后删除迁移。

EDIT You then need to delete the migration(s) after zzzz.

如果您要回滚所有迁移,或者只有一个迁移,请使用

If you want to rollback all migrations, or if you only have one migration, use

update-database -target:0

这篇关于首先以Entity Framework代码还原数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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