0

When needing to add a new column to a table using Entity Framework Code First Migrations, you simply do something like: "add-migration newColumn", then "update-database". What is the specific command to drop newColumn?

"remove-migration newColumn", then "update-database"?

1 Answer 1

2

Your question is very confusing, are you trying to revert a migration or are you trying to simply drop a column that you previously added?

Simple answer, modify your model (by removing the column) and add a new migration. This new migration will include the DropColumn command to remove the column.

If you are trying to revert a migration, you need to:

update-database -TargetMigration: "Migration" 

Where "Migration" is the name of the migration prior to the one you are trying to revert. Additionally, if you need to revert to the original state you can use:

update-database -TargetMigration: $InitialDatabase 

The MSDN article explains this pretty well: https://msdn.microsoft.com/en-us/data/jj591621.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I was trying to revert to a previous migration before the column was added.

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.