After refactoring an old project of mine I ended up with the following error upon trying to update the database with the latest migrations
There is already an object named 'AspNetRoles' in the database.

After some tricking around and starting the solution with the debugger I realized that I had moved the database migration files to another folder and as such messed up the ContextKey that the already existing migrations were named by.

The solution was either to rename the migrations already existing in the dbo.__MigrationHistory table or manually update the ContextKey (as I still wanted the migrations where I'd put them).

alt

I renamed the ContextKeyas following.

internal sealed class Configuration : DbMigrationsConfiguration<TogglCalculator.Core.Database.ApplicationDbContext>  
{
    public Configuration()
    {
        ...
        ContextKey = "TogglCalculator.Core.Database.ApplicationDbContext"; // Retrieved from the database table dbo.__MigrationHistory
    }
}