I'm using a SQL Server Database Project with Visual Studio 2012 and have the following problem when comparing and generating an update script:
In Visual Studio, I add a column with a default constraint, for example:
[NewColumn] NVARCHAR(50) CONSTRAINT [DF_ExistingTable_NewColumn] NOT NULL DEFAULT N''
Unfortunately, the name of the default constraint does not appear when:
The created update script contains the following script (no constraint name):
ALTER TABLE [dbo].[ExistingTable]
ADD [NewColumn] NVARCHAR (50) DEFAULT N'' NOT NULL;
This seems like a major oversight, so I'm wondering where to find the magic switch to include the names of default constraints in all database operations.
I think the order may be off in your definition. Try moving the "NOT NULL" part to the end of the line instead of in the middle of your constraint definition.
[NewColumn] NVARCHAR(50) CONSTRAINT [DF_ExistingTable_NewColumn] DEFAULT N'' NOT NULL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With