When you use Migrations
in Entity Framework, Migrations should be the only way you ever modify the database. That is the whole purpose of migrations, to avoid untracked DB changes.
If you don't like any change that you did, You should first rollback the migration, and then Remove the migration file, both using ef command line tool.
Please look at this question to know how to do that.
EF Migrations: Rollback last applied migration?
However, It is advisable to do forward only changes and not remove any migrations that have been deployed. This can cause mismatch in database between environments.
As stated in other answer, There is a migration snapshot file named *DbContextModelSnapshot.cs
that tracks the current state of what db should look like. Additionally, In database, You will have migration history table named __EFMigrationsHistory
. This table gives you details of migrations that have been applied. Migrations are not applied if the table has an entry for your latest migration.
If you want to understand why you were seeing the issue, you can compare your schema with the DBSnapshot.