When I tried to execute SQLQuery (generated by Update-Database -Verbose -f -Script
locally in Visual Studio) on remote database, I see the following error returned by SQL Server Management Studio:
Msg 2714, Level 16, State 6, Line 1
There is already an object named '__MigrationHistory' in the database.
How to solve this?
__MigrationHistory
is an auto-generated table used by EF to track what upgrades/patches it has applied to the database. EF is completely aware of that table and handles it on its own. You should ot create/drop/alter that table. It seems your database already has that table. If EF or your upgrade-script tries to create such table, this is strange. You need to carefully review everything and guess/learn what really has happened, because either EF went wild, or your scripts are prepared in a wrong way.