5

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?

1 Answer 1

8

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
Sign up to request clarification or add additional context in comments.

3 Comments

why should delete zzzz?
Sorry, my bad, you delete the one you don't want.
@KuttanSujith The 'zzzz' migration in Peter's example is the migration you want to rollback. So you go back to a point prior to it, and then delete it from your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.