DacHelpers 0.0.1-alpha1

.NET 7.0
This is a prerelease version of DacHelpers.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package DacHelpers --version 0.0.1-alpha1
NuGet\Install-Package DacHelpers -Version 0.0.1-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.1-alpha1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DacHelpers --version 0.0.1-alpha1
#r "nuget: DacHelpers, 0.0.1-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.1-alpha1&prerelease

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


Wrapper for Microsoft.SqlServer.Dac and Docker.DotNet to simplify integration testing against databases with DacPacs.


To deploy a DacPac to localhost or to local docker simply supply a path and a name:

var dacpacPath = "TestDb.dacpac";
var databaseName = "TestDb";
var testDatabaseHelper = await DacHelper.DeployLocal(dacpacPath, databaseName);
var testDatabaseHelper = await DacHelper.DeployDocker(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.ResetDatabase();
await testDatabaseHelper.CleanUp();

To drop an existing database before deployment simply use DropAndDeploy instead:

var testDatabaseHelper = await DacHelper.DropAndDeployLocal(dacpacPath, databaseName);

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.DeployDocker(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" }
DacHelper.DeployChangescriptsLocal(databaseName, changescripts);

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

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

Testing that a list of changescripts match a dacpac as simple as:

var changes = DacHelper.CompareLocal(dacpacPath, changescriptFolder);
Assert.That(changes, Has.Count.EqualTo(0));
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 67 1/8/2023
0.0.2-alpha6 67 12/21/2022
0.0.2-alpha5 66 12/11/2022
0.0.2-alpha4 66 12/8/2022
0.0.2-alpha3 72 12/8/2022
0.0.2-alpha2 70 12/8/2022
0.0.2-alpha1 65 12/7/2022
0.0.1-alpha1 71 12/6/2022