DacHelpers 0.0.3-alpha1

.NET 7.0
This is a prerelease version of DacHelpers.
dotnet add package DacHelpers --version 0.0.3-alpha1
NuGet\Install-Package DacHelpers -Version 0.0.3-alpha1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DacHelpers" Version="0.0.3-alpha1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DacHelpers --version 0.0.3-alpha1
#r "nuget: DacHelpers, 0.0.3-alpha1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DacHelpers as a Cake Addin
#addin nuget:?package=DacHelpers&version=0.0.3-alpha1&prerelease

// Install DacHelpers as a Cake Tool
#tool nuget:?package=DacHelpers&version=0.0.3-alpha1&prerelease


Wrapper for Microsoft.SqlServer.Dac and Docker.DotNet to simplify integration testing against databases with DacPacs. You can grab it at nuget.


To deploy a DacPac to localhost or to local docker simply supply a path and a name. Note that it drops the existing database first.

var dacpacPath = "TestDb.dacpac";
var databaseName = "TestDb";
var testDatabaseHelper = await DacHelper.DropAndDeployLocalAsync(dacpacPath, databaseName);
var testDatabaseHelper = await DacHelper.DeployDockerAsync(dacpacPath, databaseName);

The databaseTestHelper has a few helper functions to aid tests like supplying connectionstrings, resetting the database or cleaning up after use:

var connectionString = testDatabaseHelper.GetConnectionString();
await testDatabaseHelper.ResetDatabaseAsync();
await testDatabaseHelper.CleanUpAsync();

If deploying to a docker container or server that already exist just supply a ConnectionString. Note though that the returned testDatabaseHelper can't be relied on then to dispose a container':

var connectionString = testDatabaseHelper.GetConnectionString();
var testDatabaseHelper = await DacHelper.DropAndDeployAsync(dacpacPath, databaseName, connectionString);

Specifically for docker you can specify an image if you need to target a specific version of sql server:

var testDatabaseHelper = await DacHelper.DeployDockerAsync(dacpacPath, databaseName, "mcr.microsoft.com/mssql/server:2019-latest");

If using SqlCmd variables in the DacPac you can supply a dictionary with mappings:

var variableMap = new Dictionary<string, string>() { { "Registration", "Registration" } }
var testDatabaseHelper = DacHelper.DropAndDeployLocalAsync(dacpacPath, databaseName, variableMap);

To deploy a list of changescripts instead of a DacPac locally:

var folder = "changescripts/"
var changescripts = new List<string> = { $"{folder}001-addSchemas.sql", $"{folder}002-addEmployeeTable", $"{folder}003-addOfficeTable" }
await DacHelper.DeployChangescriptsLocalAsync(databaseName, changescripts);

Or to simply deploy a folder of changescripts locally (in alphabetical order):

var folder = "changescripts/"
await DacHelper.DeployChangescriptsLocalAsync(databaseName, folder);

Testing that a list of changescripts match a DacPac is as simple as:

var deployReport = await DacHelper.CompareLocalAsync(dacpacPath, changescriptFolder);
Assert.That(deployReport.Operations, Has.Count.EqualTo(0));

For more usage also check out the projects tests at github.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.3-alpha1 78 1/8/2023
0.0.2-alpha6 85 12/21/2022
0.0.2-alpha5 76 12/11/2022
0.0.2-alpha4 76 12/8/2022
0.0.2-alpha3 82 12/8/2022
0.0.2-alpha2 78 12/8/2022
0.0.2-alpha1 76 12/7/2022
0.0.1-alpha1 81 12/6/2022