Webdeploy failed to apply migration saying problem between lines "1609" and "1616" of a script
Here exactly
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20170331103534_corporate7') BEGIN CREATE UNIQUE INDEX [IX_Persons_CorporatePersonId] ON [Persons] ([CorporatePersonId]) WHERE [CorporatePersonId] IS NOT NULL; END; GO
error is - Invalid column name 'CorporatePersonId'
Migration 20170331103534_corporate7 already applied to DB as many other migration after it. I double checked connection string. All point to DB where 20170331103534_corporate7 applied long time ago
Full error
Severity Code Description Project File Line Suppression State
Error Web deployment task failed. (Ошибка при выполнении сценария базы данных. Ошибка произошла между следующими строками сценария: "1609" и "1616". Дополнительные сведения могут содержаться в подробном журнале. Начало команды следующее:
"IF NOT EXISTS(SELECT * FROM [__EFMigrationsHisto"
Invalid column name 'CorporatePersonId'. http://go.microsoft.com/fwlink/?LinkId=178587 Дополнительные сведения: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE.)
Failed to publish the database. This can happen if the remote database cannot run the script. Try modifying the database scripts, or disabling database publishing in the Package/Publish Web properties page. If the script failed due to database tables already
exist, try dropping existing database objects before creating new ones. For more information on doing these options from Visual Studio, see http://go.microsoft.com/fwlink/?LinkId=179181.
Error details:
Ошибка при выполнении сценария базы данных. Ошибка произошла между следующими строками сценария: "1609" и "1616". Дополнительные сведения могут содержаться в подробном журнале. Начало команды следующее:
"IF NOT EXISTS(SELECT * FROM [__EFMigrationsHisto"
Invalid column name 'CorporatePersonId'. http://go.microsoft.com/fwlink/?LinkId=178587 Дополнительные сведения: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE.
Invalid column name 'CorporatePersonId'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Web.Deployment.DBStatementInfo.Execute(DbConnection connection, DbTransaction transaction, DeploymentBaseContext baseContext, Int32 timeout) CETDB 0