使用相同的数据库更新数据库后,是否可以删除 EF Core 数据库迁移? [英] Is it possible to remove an EF Core Database migration after the database is updated with the same

查看:32
本文介绍了使用相同的数据库更新数据库后,是否可以删除 EF Core 数据库迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 .NET EF 核心中,是否可以在通过Update-database"更新数据库后删除/恢复数据库迁移?命令?

In .NET EF core, Is it possible to remove/revert a Database migration after the database is updated by "Update-database" command?

推荐答案

是的,这是可能的,但前提是它是最后一次迁移,或者您在它之后恢复所有迁移.

Yes, it's possible, but only if it is the last migration or if you revert all migrations after it.

要恢复所有迁移,包括所需的迁移,请使用 -Migration 相同Update-Database 命令的参数,并在之前传递所需的迁移名称/ID(或特殊值0 如果是第一个)

To revert all migrations including the desired, use the -Migration parameter of the same Update-Database command and pass the name/id of the migration before the desired (or special value 0 if it is the first)

Update-Database MigrationBeforeTheOneYouWantToRevert

有关详细信息,请参阅应用迁移 - 命令行工具部分.

For more info, see Applying Migrations - Command-line tools sections of the official EF Core documentation.

这篇关于使用相同的数据库更新数据库后,是否可以删除 EF Core 数据库迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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