There is already an object named in the database

it seems there is a problem in migration process, run add-migration command in “Package Manager Console”: Add-Migration Initial -IgnoreChanges do some changes, and then update database from “Initial” file: Update-Database -verbose Edit: -IgnoreChanges is in EF6 but not in EF Core, here’s a workaround: https://stackoverflow.com/a/43687656/495455

Debug code-first Entity Framework migration codes

I know that EF Code First Migrations is relatively new tool but don’t forget about you are still in .NET. So you can use: if (System.Diagnostics.Debugger.IsAttached == false) { System.Diagnostics.Debugger.Launch(); } After that you can see your InnerException. Or you can use try…catch statement like this: Exception handling Entity Framework

Entity Framework Migrations renaming tables and columns

Nevermind. I was making this way more complicated than it really needed to be. This was all that I needed. The rename methods just generate a call to the sp_rename system stored procedure and I guess that took care of everything, including the foreign keys with the new column name. public override void Up() { … Read more

Entity Framework – Start Over – Undo/Rollback All Migrations

You can rollback to any migration by using: Update-Database -TargetMigration:”MigrationName” If you want to rollback all migrations you can use: Update-Database -TargetMigration:0 or equivalent: Update-Database -TargetMigration:$InitialDatabase In some cases you can also delete database and all migration classes.

Reset Entity-Framework Migrations

You need to : Delete the state: Delete the migrations folder in your project; And Delete the __MigrationHistory table in your database (may be under system tables); Then Run the following command in the Package Manager Console: Enable-Migrations -EnableAutomaticMigrations -Force Use with or without -EnableAutomaticMigrations And finally, you can run: Add-Migration Initial

EF Migrations: Rollback last applied migration?

I want to add some clarification to this thread: Update-Database -TargetMigration:”name_of_migration” What you are doing above is saying that you want to rollback all migrations UNTIL you’re left with the migration specified. Thus, if you use GET-MIGRATIONS and you find that you have A, B, C, D, and E, then using this command will rollback … Read more