简体   繁体   中英

Revert database in Entity Framework code-first

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.

How can I do this?

Yes - it's straightforward. Use

Update-Database -TargetMigration:zzzz

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM