EF Migration object already exists error
Best and working For me idea is to comment all the code in UP and Down functions of Initial migration file and then fire
dotnet ef database update
this should work fine,make sure you update migration before commenting out initial migration
This error appears when you deleted previous migrations and your new migration try to create new table that already exist. Recover previous migration and everything will be ok.
try to Run the
Add-Migration InitialCreate –IgnoreChanges
command in Package Manager Console. This creates an empty migration with the current model as a snapshot. and then Run the
Update-Database
command in Package Manager Console. This will apply the InitialCreate migration to the database. Since the actual migration doesn’t contain any changes, it will simply add a row to the __MigrationsHistory table indicating that this migration has already been applied.
see this
then change your models and add migration.
another approach is to simply comment all the code on up and down methods