I'm having trouble with a migration that seems to have been wrongly deleted by EF core. It says I have to manually delete some file, since the migration file was not found, but I can't find a guide on how I'm supposed to delete that.
- I had my initial create migration
- I added a new one for creating a couple more columns in a table
- I didn't realize that mi project was set to pgsql instead of sqlite
- I deleted the migration (never applied database update)
- Ef core delete command deleted the migration files on ./Data/Migrations
- I set sqlite
- I added a new migration
- The new migration was on pgsql again
- Delete migration tries to delete the (step 2) migration instead of (step 6) migration and fails.
It says No file named '20220308_Migration2.cs' was found. You must manually remove the migration class 'Migration2', hence the question.
My commands for adding and removing and listing the migrations were the followings:
dotnet ef migrations add name -c MyContext -p .\Project.Db\Project.Db.csproj -o .Project.Db\Data\Migrations -s .\Project.Server\Project.Server.csproj
dotnet ef migrations delete name -c MyContext -p .\Project.Db\Project.Db.csproj -s .\Project.Server\Project.Server.csproj
dotnet ef migrations delete name -c MyContext -p .\Project.Db\Project.Db.csproj -s .\Project.Server\Project.Server.csproj
After all done, if I execute the list command, output shows:
Migration1 (pending)
Migration2 (pending)
Where Migration1 is the initial create and Migration2 is the migration applied on step2.
The files I have on Data/Migrations folder are the ones corresponding to Migration1 and Migration3 (step 6)
Another questions.
Where does the list command data comes from? is there a secret database or a hidden caché folder?
If I just delete the Data/Migrations folder, will I be able to start over with the migrations?
Thanks