Will SSDT publish always fail with "Data Loss May Occur" when table is rebuilt? Consider the following scenario:


We have a SSDT database project.
We add a new column to the middle of a table.
This forces the database project to rebuild the table in order to deploy the change.
We publish this SSDT database project  with the setting “Block incremental deployment if data loss might occur” enabled.
Because we have the above setting enabled, and (also, I think) the table is being rebuilt the deployment (correctly) throws an error saying data loss may occur.


My question is this: Can we rely on the fact that whenever the table needs to be rebuilt as part of a SSDT publish this error will be thrown?
Yes, you can rely on that. When you enable the "BlockOnDataLoss" attribute what actually happens is that SSDT adds to the deployment script a check like this one

IF EXISTS(SELECT 1 FROM TableToChange)
BEGIN
     RAISEERROR ...
END