Removing the last migration – EF

I was working on a .net project yesterday. I did some migrations and that included deletion of a column in the database ( Code-first approach right? ).

After a while, I thought that was unnecessary and I needed the column to be present. So what I did was, I deleted the migration file and ran db update command. Though it ran successfully, It didn’t bring my deleted column.

After a quite long time, after checking this up on the internet, I found that before deleting the migration – we might need to revert to an older migration. If we remove the migration before hand, the entity framework will not know it.

So it might be something like,

dotnet ef database update YourMigrationName

This brought my deleted column.

Leave a Reply

Your email address will not be published. Required fields are marked *