Automatic migration was not applied because it would result in data loss

When you are using Entity Framework and try to use the migration tool you may have this message.

Automatic migration was not applied because it would result in data loss

I had this error while doing this exact command inside the Package Manager Console.

Update-Database -Verbose

This happen because you have some data inside the table and the migration tool want to drop the table. This create a conflict for the migration tool and instead of taking the decision of deleting the data it show this error. If you are using the migration tool because you want to create the whole database and seed data with the seed method than you can force the table drop.

You simply need to use force.

Update-Database -Verbose -Force

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

1 thought on “Automatic migration was not applied because it would result in data loss

  1. Pingback: Patrick Desjardins' Blog » How to rebuild the database from Entities with Membership table

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.