4

I have a dacpac file which I am deploying via an application using the DacServices library. I have the following code to do it:

var dp = DacPackage.Load(dacpacPath);
var dbDeployOptions = new DacDeployOptions
{
    BlockOnPossibleDataLoss = false
};
var dbServices = new DacServices(WebConfigHelper.GetDbConnectionString(webConfigPath));
dbServices.Deploy(dp, WebConfigHelper.GetDbName(webConfigPath), true, dbDeployOptions);

The issue is that with this code, the target database always has it's recovery model altered to "Full" which is what is set in the SSDT database project (which generates the dacpac).

The various target databases which we deploy to use a variety of database properties, and we don't know the target DBs recovery model. Some use simple, and some use full - we don't want to change it.

How can I alter this code so that it doesn't make any alterations to the target database properties? I have already tried unticking the "Deploy database properties" setting in the database project, but the above code seems to override that.

Laurence Frost
  • 2,759
  • 3
  • 28
  • 45
  • 2
    Have you tried DacDeployOptions.ScriptDatabaseOptions = false? – Dan Guzman Jan 30 '15 at 13:46
  • Fantastic thank you. I looked through the list of properties twice, and somehow missed that twice. If you write this as an answer below I'll accept it as the solution. – Laurence Frost Jan 30 '15 at 14:28

1 Answers1

4

The DacDeployOptions class includes a ScriptDatabaseOptions Boolean that can be set to false to keep the existing database settings or use defaults for a new one.

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
Dan Guzman
  • 43,250
  • 3
  • 46
  • 71