Getting error while executing DACPAC file (using sqlpackage.exe)

947 views Asked by At

I am getting below error while executing DACPAC file using SQLPackage.

The column [dbo].[Temp].[GMTOffset] on table [dbo].[Temp] must be added, but the column has no default value and does not allow NULL values. If the table contains data, the ALTER script will not work. To avoid this issue you must either: add a default value to the column, mark it as allowing NULL values, or enable the generation of smart-defaults as a deployment option.

PowerShell script - & $using:SqlPackagePath /Action:Publish /tu:$using:DatabaseUsername /tp:$using:DatabasePassword /tsn:$using:ServerInstance /tdn:"$_" /sf:$using:DacpacLocation /p:BlockOnPossibleDataLoss=False

I have set 'Generate smart defaults, when applicable' setting in publish profile of the DB project and execute the PowerShell script after compiling the project, however, still getting this error. Any pointers or help would be appreciated.

1

There are 1 answers

0
user13624867 On

This error was resolved after specifying this option on the command line like below as @Peter also mentioned.

& $using:SqlPackagePath /Action:Publish /tu:$using:DatabaseUsername /tp:$using:DatabasePassword /tsn:$using:ServerInstance /tdn:"$_" /sf:$using:DacpacLocation /p:GenerateSmartDefaults=True /p:BlockOnPossibleDataLoss=False