Auto applied migrations using EF Core 7.0.14

79 views Asked by At

When I make a new migration (Add-Migration Example) , and then I try to get all the migrations (Get-Migration) I find that the "applied" field is "True" without even using (Update-Database),furthermore when I try to revert all migrations back (Update-Database 0) , it tells me it has succeeded , and when I check that using Sql Server Object Explorer , I find that it really succeeded , but again using(Get-Migration) I find that again "applied" field is "True" ,and to make everything even worse , when I type (Remove-Migration) it tells me that the last migration is applied and you have to revert it to be able to remove it ,and I find that the migrations has been applied to the database again ,any idea what could cause this problem? (Sorry if you find my English is bad, it's not my primary language :) )

I did Try to remove the migrations and the database manually my self but it didn't result in anything , the problem remains.

1

There are 1 answers

5
Qiang Fu On

Get-migration actually checks the "_efmigrationshistory" table. If a migration has been updated to database. The migration file name will be recorded in this "_efmigrationshistory" table.

enter image description here

enter image description here

You probably has updated the same name migration file before. So the name has been recorded. And when you check by Get-migration, it detected the same name and returned as "applied:true".