Saturday 3 October 2015

Source schema drift detected. press compared to refresh in Visual Studio 2013

I was trying to compare database object schema by using visual studio 2013. Many times its work for me but sometime i used to got an error while updating or generating script. I tried many times but i was stuck in the problem.

Message:
Source schema drift detected. press compared to refresh

And in the Project\bin\Debug\project.sql
GO
:on error exit
GO
/*
Detect SQLCMD mode and disable script execution if SQLCMD mode is not supported.
To re-enable the script after enabling SQLCMD mode, execute the following:
SET NOEXEC OFF;
*/
:setvar __IsSqlCmdEnabled "True"
GO
IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
    BEGIN
        PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
        SET NOEXEC ON;
    END


GO

VS and SQL server version were matched, i went to Microsoft site. And i got a hint that worked for me.

Solution:

I closed the comparison solution, created a new one and it worked fine.