question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DacPackage.UpdateModel() corrupts package, calling DacServices.GenerateDeployScript() fails afterwards.

See original GitHub issue

Creating a new issue from #242 per request from @zijchen

  • SqlPackage or DacFx Version: 162.0.52
  • .NET Framework (Windows-only) or .NET Core: net48 and net6.0
  • Environment (local platform and source/target platforms): N/A

Steps to Reproduce:

The issue repros when targeting net6.0 (likely netcoreapp3.1), it does not repro on net4.8:

var dacpacFromSqlproj = "OutputOfSqlproj.dacpac";

using var buffer = new MemoryStream();
using (var temp = File.OpenRead(dacpacFromSqlproj))
{
    temp.CopyTo(buffer); // to avoid modifying the original .dacpac file
}

buffer.Position = 0;
using (var dacpac = DacPackage.Load(buffer, DacSchemaModelStorageType.Memory, FileAccess.ReadWrite))
{
    dacpac.UpdateModel(
        new TSqlModel(SqlServerVersion.SqlAzure, new TSqlModelOptions()),
        new PackageMetadata());
}

buffer.Position = 0;
using var dacpac2 = DacPackage.Load(buffer);

var dacServices = new DacServices(@"Data Source=(LocalDB)\MSSQLLocalDB;Integrated Security=true");

// Next line throws when on net6.0 but works on net4.8:
// Microsoft.SqlServer.Dac.DacServicesException: An error occurred during deployment plan generation.Deployment cannot continue.
// ---> Microsoft.Data.Tools.Schema.Sql.Deployment.DeploymentFailedException: The calculated checksum for model.xml in the package is different from the saved checksum.
// ---> Microsoft.Data.Tools.Schema.Sql.Build.SqlPackageException: The calculated checksum for model.xml in the package is different from the saved checksum.
dacServices.GenerateDeployScript(dacpac2, "TargetDatabaseName");

Did this occur in prior versions? If not - which version(s) did it work in? Prior versions of DacFx failed at the DacPackage.Load(buffer) step (after the UpdateModel() call) when on netcore 3.1 or net6.0, see #242 for details. The issue repros on net6.0 runtime but not on net48.

(DacFx/SqlPackage/SSMS/Azure Data Studio)

Issue Analytics

  • State:open
  • Created 4 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
smichtchcommented, Jun 7, 2023

We have fixed this issue and should be in the August release. Meanwhile you can give it a try with our preview release: 162.1.39-preview

@zijchen, I tried the new version and can confirm it works, thanks for getting this fixed!

1reaction
czb182commented, Jun 7, 2023

I’ve been following dacfx development for a while, at least to me it seems to be moving faster. Any chance of speeding up release cadence, maybe monthly or so? @zijchen

Read more comments on GitHub >

github_iconTop Results From Across the Web

DacServices GenerateDeployScript Fails with SQL 2017
After installing SQL 2017 (14.0.1000.169) my dacServices.GenerateDeployScript c# code deployments fail with the error listed.
Read more >
Deploy Database dacpac with Powershell: Exception ...
I am thinking its due to me having SQL Server 2016. Trying to understand what the error message means. Here is the code:...
Read more >
DacServices.GenerateDeployScript Method
Create T-SQL script that can be used to deploy the differences between the schemas of the supplied source and target DacPackage instances to...
Read more >
Method not found: 'Void Microsoft.SqlServer.TransactSql'
DeployDacPacWithOptions() fails with System. ... GenerateDeployScript(DacPackage package, String targetDatabaseName, DacDeployOptions ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found