This documentation is archived and is not being maintained.

DacPackageExtensions.UpdateModel Method (DacPackage, TSqlModel, PackageMetadata)

SQL Server 2014

Updated: April 20, 2017

Updates the model in a DacPackage, replacing the current model with a new one. Before updating, the model will be validated and if errors are encountered a DacServicesException will be thrown. If callers wish to block on warnings as well as errors, they must validate the model by calling Validate and checking if any errors or warnings are included in the messages returned. Note: only the model is replaced - all other artifacts such as refactor log, pre-deployment script, post-deployment script and and contributor artifacts are not altered. If any of these artifacts rely on elements that are no longer in the updated model then deployment may fail. It is the responsibility of the caller to ensure that these artifacts are consistent with the new model. The Package API can be used to update other artifacts such as the refactor log and scripts and keep them consistent with the updated model. These artifacts are stored as package parts and are identified by their URI. Package parts can be examined using GetParts. Please refer to the Package API for further information about updating package parts.

Namespace:   Microsoft.SqlServer.Dac
Assembly:  Microsoft.SqlServer.Dac.Extensions (in Microsoft.SqlServer.Dac.Extensions.dll)

public static void UpdateModel(
	this DacPackage dacPackage,
	TSqlModel newModel,
	PackageMetadata packageMetadata


Type: Microsoft.SqlServer.Dac.DacPackage

The DacPackage to be updated

Type: Microsoft.SqlServer.Dac.Model.TSqlModel

The TSqlModel representing the model to save into the package.

Type: Microsoft.SqlServer.Dac.PackageMetadata

The PackageMetadata describing the name, version and description to use for the DacPackage, or null if the package information should remain the same.

Exception Condition

If the DacPackage contains data.


If there are any errors saving the model to the package, including errors validating the model.


If the dacPackage was not loaded with ReadWrite.


If the dacPackage or newModel parameters are null.

Return to top