Publish dacpac in single-user mode using Microsoft.SqlServer.Dac.DacServices

I want to publish dac pac in single user mode to prevent unnecessary database changes when updating the database. For this, I used the Deploy function in Microsoft.SqlServer.Dac.DacServices .

This function has the DacDeployOptions parameter. I set DeployDatabaseInSingleUserMode = true to these parameters. Although it is set to true, I can perform the db operation during the dacpac deployment.

Is there anything I don't see? or is there any other way to achieve this.

Help will be appreciated!

+5
source share
1 answer

What version of DacFX are you using? If this is not the last, it will work best, because many of the old ones do not understand the parameters that you specified very well.

Alternatively, you can do this (this is what I did, instead of getting DacFX to work correctly.

  ServerConnection connection = new ServerConnection(ServerName); Server sqlServer = new Server(connection); Database QADatabase = sqlServer.Databases[DatabaseName]; QADatabase.DatabaseOptions.UserAccess = DatabaseUserAccess.Single; QADatabase.Alter(TerminationClause.RollbackTransactionsImmediately); QADatabase.Refresh(); //DACPAC logic goes here QADatabase.DatabaseOptions.UserAccess = DatabaseUserAccess.Multiple; QADatabase.Alter(TerminationClause.RollbackTransactionsImmediately); QADatabase.Refresh(); 
0
source

All Articles