Can't deploy .dacpac by following technet documentation


I'm trying to follow the msdn documentation to deploy a dacpac on SQL Server 2012 which is installed on my local machine. Here's the link to the documentation:

The script I try to execute is:


param (

[string]$dacpacPath = $(throw "-dacpacPath is required."),

[string]$dacName = $(throw "-dacName is required."),

[string]$serverName = $(throw "-servereName is required.")



$ErrorActionPreference = "Stop"



Import-Module sqlps -DisableNameChecking



$srv = Get-Item "SQLSERVER:\SQL\$serverName"


## Open a Common.ServerConnection to the same instance.

$serverconnection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection($srv.ConnectionContext.SqlConnectionObject)


$dacstore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($serverconnection)


## Subscribe to the DAC events.

$dacstore.add_DacActionStarted({Write-Host `n`nStarting at $(get-date) :: $_.Description})

$dacstore.add_DacActionFinished({Write-Host Completed at $(get-date) :: $_.Description})


## Delete previous DAC if exists and drop the database

$dacstore.Uninstall($dacName, [Microsoft.SqlServer.Management.Dac.DacUninstallMode]::DropDatabase)


## Load the DAC package file.

$fileStream = [System.IO.File]::Open($dacpacPath,[System.IO.FileMode]::OpenOrCreate)

$dacType = [Microsoft.SqlServer.Management.Dac.DacType]::Load($fileStream)


## Deploy the DAC and create the database.

$evaluateTSPolicy = $true

$deployProperties = New-Object Microsoft.SqlServer.Management.Dac.DatabaseDeploymentProperties($serverconnection, $dacName)

$dacstore.Install($dacType, $deployProperties, $evaluateTSPolicy)





When I try to run the script from powershell console I get the following exception:

New-Object : Cannot find type [Microsoft.SqlServer.Management.Dac.DacStore]: verify that the assembly containing this type is loaded.

At C:\src\commerce\private\CommerceSearch\relevance\MTurkJudgmentSystem\Publish\deploy-db.ps1:19 char:13

+ $dacstore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($serverconnec ...

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException

    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

As the documentation states, calling Import-Module sqlps -DisableNameChecking should load all the assemblies automatically, but for some reason this doesn't happen.

I've tried installing packages from here but it didn't help.

What am I missing from reading the docs?





No Data
Reply Children
No Data