DacPackage.UpdateModel() corrupts package, calling DacServices.GenerateDeployScript() fails afterwards.
See original GitHub issueCreating a new issue from #242 per request from @zijchen
- SqlPackage or DacFx Version:
162.0.52
- .NET Framework (Windows-only) or .NET Core:
net48
andnet6.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:
- Created 4 months ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zijchen, I tried the new version and can confirm it works, thanks for getting this fixed!
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