DacPackageExtensions.UpdateModel Method

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)

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Sub UpdateModel ( _
    dacPackage As DacPackage, _
    newModel As TSqlModel, _
    packageMetadata As PackageMetadata _
)
'Usage
Dim dacPackage As DacPackage 
Dim newModel As TSqlModel 
Dim packageMetadata As PackageMetadata 

dacPackage.UpdateModel(newModel, _
    packageMetadata)
public static void UpdateModel(
    this DacPackage dacPackage,
    TSqlModel newModel,
    PackageMetadata packageMetadata
)
[ExtensionAttribute]
public:
static void UpdateModel(
    DacPackage^ dacPackage, 
    TSqlModel^ newModel, 
    PackageMetadata^ packageMetadata
)
static member UpdateModel : 
        dacPackage:DacPackage * 
        newModel:TSqlModel * 
        packageMetadata:PackageMetadata -> unit
public static function UpdateModel(
    dacPackage : DacPackage, 
    newModel : TSqlModel, 
    packageMetadata : PackageMetadata
)

Parameters

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DacPackage. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=sql.110) or https://msdn.microsoft.com/en-us/library/bb383977(v=sql.110).

Exceptions

Exception Condition
DacServicesException

If the DacPackage contains data.

DacServicesException

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

DacServicesException

If the dacPackage was not loaded with ReadWrite.

ArgumentNullException

If the dacPackage or newModel parameters are null.

See Also

Reference

DacPackageExtensions Class

Microsoft.SqlServer.Dac Namespace