Microsoft.SqlServer.DacFx 170.4.80-preview

Prefix Reserved
This is a prerelease version of Microsoft.SqlServer.DacFx.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Microsoft.SqlServer.DacFx --version 170.4.80-preview
                    
NuGet\Install-Package Microsoft.SqlServer.DacFx -Version 170.4.80-preview
                    
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="Microsoft.SqlServer.DacFx" Version="170.4.80-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.SqlServer.DacFx" Version="170.4.80-preview" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.SqlServer.DacFx" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.SqlServer.DacFx --version 170.4.80-preview
                    
#r "nuget: Microsoft.SqlServer.DacFx, 170.4.80-preview"
                    
#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.
#:package Microsoft.SqlServer.DacFx@170.4.80-preview
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.SqlServer.DacFx&version=170.4.80-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.SqlServer.DacFx&version=170.4.80-preview&prerelease
                    
Install as a Cake Tool

Microsoft SQL Server Data-Tier Application Framework (DacFx) Nuget Package

Overview

The Microsoft SQL Server Data-Tier Application Framework (DacFx) is a .NET library which provides application lifecycle services for database development and management for Microsoft SQL databases. DacFx supports various database deployment and management scenarios, including extracting / exporting a live database to a DAC package, deploying a DAC package to a new or existing database, and migrating from on-premises to Microsoft Azure. DacFx can target all supported versions of SQL Server, as well as Microsoft Azure SQL and SQL in Fabric.

📘 DacFx .NET API documentation

📗 SQL projects database DevOps documentation

If you would like to use DacFx functionality from the command-line for creating and deploying .dacpac and .bacpac packages, please use the SqlPackage CLI as a dotnet tool or downloadable exe. Learn more about SqlPackage from http://aka.ms/sqlpackage.

Usage

The following examples demonstrate some basic functionality of the DacFx API. For more detailed examples, please refer to the DacFx API documentation.

Example: Deploy a .dacpac to a database

using Microsoft.SqlServer.Dac;

string dacpacPath = "path\\to\\your.dacpac";
string connectionString = "your-database-connection-string";
DacServices dacServices = new DacServices(connectionString);
DacPackage dacPackage = DacPackage.Load(dacpacPath);
dacServices.Deploy(dacPackage, "TargetDatabaseName", upgradeExisting: true);

Example: Extract a database to a .dacpac

using Microsoft.SqlServer.Dac;
string connectionString = "your-database-connection-string";
string dacpacOutputPath = "path\\to\\output.dacpac";
DacServices dacServices = new DacServices(connectionString);
DacExtractOptions extractOptions = new DacExtractOptions();
dacServices.Extract(dacpacOutputPath, "SourceDatabaseName", "SourceDatabaseName", extractOptions);

Example: Extract a database to .sql files organized by object type and schema

using Microsoft.SqlServer.Dac;
string connectionString = "your-database-connection-string";
string sqlOutputDirectory = "path\\to\\output\\directory";
DacServices dacServices = new DacServices(connectionString);
DacExtractOptions extractOptions = new DacExtractOptions
{
    ExtractTarget = DacExtractTarget.SchemaObjectType
};
dacServices.Extract(sqlOutputDirectory, "SourceDatabaseName", "SourceDatabaseName", extractOptions);

Component Links Summary
SqlPackage 📦 Tool<br/>📗 Docs Microsoft.SqlPackage is a cross-platform command-line utility for creating and deploying .dacpac and .bacpac packages. SqlPackage can be installed as a dotnet tool.
DacpacVerify 📦 Tool Microsoft.DacpacVerify is a cross-platform command-line utility for checking that two .dacpac packages match, including pre/post-deployment scripts and SQLCMD variables.
Dacpacs.(Master,Msdb) 📦 Master<br/>📦 Msdb Microsoft.SqlServer.Dacpacs.Master and Microsoft.SqlServer.Dacpacs.Msdb is a set of NuGet packages containing .dacpac files for Microsoft SQL Server system databases (master, msdb) with versions across SQL Server 2008 (100) through SQL Server 2022 (160).
Dacpacs.Azure.Master 📦 NuGet Microsoft.SqlServer.Dacpacs.Azure.Master is a NuGet package containing a .dacpac file for the Azure SQL Database master database.
Dacpacs.DbFabric 📦 NuGet Microsoft.SqlServer.Dacpacs.DbFabric is a NuGet package containing a .dacpac file for the SQL database in Fabric system objects.
Dacpacs.Synapse.Master 📦 NuGet Microsoft.SqlServer.Dacpacs.Synapse.Master is a NuGet package containing a .dacpac file for the Azure Synapse Analytics master database.
Dacpacs.SynapseServerless.Master 📦 NuGet Microsoft.SqlServer.Dacpacs.SynapseServerless.Master is a NuGet package containing a .dacpac file for the Azure Synapse Analytics serverless SQL pools master database.
ScriptDom 📦 NuGet<br/>🛠️ Code<br/>📘 API Docs Microsoft.SqlServer.TransactSql.ScriptDom is a NuGet package containing the Transact-SQL parser ScriptDOM. The source code is licensed MIT.
Microsoft.Build.Sql 📦 NuGet<br/>📗 Docs<br/>🛠️ Code Microsoft.Build.Sql is a .NET project SDK for SQL projects, compiling T-SQL code to a data-tier application package (dacpac).
Project Templates 📦 NuGet<br/>🛠️ Code Microsoft.Build.Sql.Templates is a set of .NET project templates for SQL projects.

Support

Open issues at DacFx GitHub

Important Notice: Breaking Changes Due to Public Key Update

We would like to inform you about an important change in DacFx NuGet that may impact your applications. We have updated the public key in the DLLs included in this package. This change is crucial for enhancing the security and integrity of our assembly but may cause breaking changes in your C# applications.

Impact of Public Key Change

  • Build Failures: Applications referencing the old DLL with the previous public key will fail to build.
  • Runtime Errors: Applications may experience runtime errors if the old DLL is loaded dynamically or through reflection.
  • Configuration Updates: Any configuration files or settings that reference the old public key will need to be updated to the new key.

Steps to Address the Change

To mitigate the impact of this change, we recommend the following steps:

  • Update Package References: Ensure that you update your NuGet package reference to the latest version that includes the DLL with the new public key.
  • Rebuild Your Application: Rebuild your application to ensure it correctly references the new DLL.
  • Thorough Testing: Conduct comprehensive testing to identify and resolve any issues resulting from the public key change.
  • Update Documentation: Ensure that all relevant documentation and configuration files are updated to reflect the new public key.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core