I added a bunch of foreign keys to the database project when previously there weren’t any. In the generated sql file (sql/debug/$projectname.sql) I see a part that starts with
PRINT N'Checking existing data against newly created constraints';
GO
USE [$(DatabaseName)];
GO
ALTER TABLE [dbo].[table1] WITH CHECK CHECK CONSTRAINT [FK_1];
ALTER TABLE [dbo].[table1] WITH CHECK CHECK CONSTRAINT [FK_2];
and on it goes.
How can I stop the database project from generating this section that checks the data against the new constraints? I tried creating the foreign keys using
ALTER TABLE dbo.table1 WITH NOCHECK
ADD CONSTRAINT [FK_1]
FOREIGN KEY (blah)
REFERENCES Table2 (blah2)
but no dice. Any suggestions?
Aha, there’s an advanced option called checkNewConstraints in the Database.sqldeployment properties page under the properties folder. That should do the trick.