12

I have a dacpac that has set the BlockOnPossibleDataLoss set to false, however the deployment is blocked when I run it with sqlpackage.exe, telling me "The column [a] is being dropped, data loss could occur."

However when I use the exact same deployment profile and publish from Visual Studio 2012 it goes through.

8

Have you tried executing sqlpackage.exe with /p:BlockOnPossibleDataLoss=false in the command line?

I just used SQLPackage.exe to create a .dacpac file of my test database, then I pubished it with the /p:BlockOnPossibleDataLoss=false option, and it overwrote my database.

  • I tried that, however it didn't help. I did narrow down the problem a bit more. I execute the package within a powershell script and there it is within a try catch block. It seems that even though the flag is set sqlpackage.exe creates an exception (I would expect otherwise) – nojetlag Nov 11 '13 at 9:07
  • 1
    This worked great for us while doing a Database deployment task in our Visual Studio Team System build to our Azure Database. – Dan Csharpster May 11 '17 at 18:20
2

Finally found the issue, I execute sqlpackage.exe within a powershell script where the error handling is set like

$Script:ErrorActionPreference = "Inquire"

since i never got the Inquire I assumed the problem was with sqlpackage.exe, however I had another powershell script included after the ErrorActionPreference was set, turned out the included script also had the ErrorActionPreference set, but to "Stop". Still I believe if I have set BlockOnPossibleDataLoss=false it should not result in an error, but at least I now have a way to handle it.

2

I had the same issue and /p:BlockOnPossibleDataLoss=false don't work.

The final solution was in my case, that it also has to be set in the debug settings of the project file:

Project debug settings

Hope this helps someone! :)

  • and if you "publish" directly, you'll have to set up this option in the "advanced" publish option as well! – Pac0 Jul 16 '19 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.