Recently I run add-migration
command, and I have some mistakes, so I run remove-migration
to undo it. But when I run add-migration
again, it said: The name 'blablabla' is used by an existing migration
. How to fix this. I already double check Migration folder, there is no migration that have that name.
Delete bin and obj folder in the src of your project, rebuild and It should allow you to add migrations with the same name. This works for me.
It seems that they are cached in the bin and obj folder and when you try to add a new migration with the same name it checks those folders and throws you the error message.
Tested on .net core 2.2
Try to build your application after removing migration:
dotnet ef migrations add YourMigration
dotnet ef migrations remove
dotnet build
dotnet ef migrations add YourMigration
dotnet build
and regular build? –
Trope Check the \Migrations folder, delete the 'blala' name, both .cs. and Designer.cs. Run the add-migration again , should work.
Check the "Data" folder. There are migrations there also. Delete the folder, re-run the build and should work.
If you have access to your database, Go to the Database and Remove that Last Migration you add in the migration table. Then it should work again without any problem.
maybe its exclude from the project. check TFS or file explorer.
Build -> Clean Solution does the job.
© 2022 - 2024 — McMap. All rights reserved.
add-migration Blablabla
, it create a cs file with time stamp before the name "Blablabla" (Ex: 20200313092540_Blablabla), I don't see how it can be douplicated? – Trope