DACExtensions contains samples that extend Data-Tier Applications using DacFx. These samples include deployment contributors and static code analysis rules that can be used with Visual Studio as well as examples of how to use the DacFx public mode
MIT License
125
stars
41
forks
source link
Microsoft.SqlServer.Dac.DacServicesException for PostDeployment only project #31
I'm using the nuget package Microsoft.SqlServer.DACFx 150.4441.1-preview
I have a database project used for sample data that only contains post deployment scripts.
The publish profile works fine in Visual Studio (2019), however, the same publish profile fails with the exception:
Microsoft.SqlServer.Dac.DacServicesException : Cannot deploy to existing database when upgrading has been disabled.
var dac = new DacServices(publishConnString);
using (var dbPackage = DacPackage.Load(SampleData, DacSchemaModelStorageType.Memory))
{
var publishProfile = DacProfile.Load(PublishProfileSampleData);
var options = publishProfile.DeployOptions;
//Tried setting the below options - no change in error
//options.BlockOnPossibleDataLoss = false;
//options.BlockWhenDriftDetected = false;
//options.AllowIncompatiblePlatform = true;
//PostDeployment script is present - this looks like the correct sql
string sql = new StreamReader(dbPackage.PostDeploymentScript).ReadToEnd();
//fails with Cannot deploy to existing database when upgrading has been disabled.`
dac.Deploy(dbPackage, dbName, options: options);
}
I'm using the nuget package Microsoft.SqlServer.DACFx 150.4441.1-preview
I have a database project used for sample data that only contains post deployment scripts.
The publish profile works fine in Visual Studio (2019), however, the same publish profile fails with the exception:
Microsoft.SqlServer.Dac.DacServicesException : Cannot deploy to existing database when upgrading has been disabled.
The publish profile is pretty basic:
The publishing code is: