问题描述
在 .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 数据库迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!