找不到Microsoft.SqlServer.Dac.dll
z_lim 2015-08-06 10:01:54 我们现在有个要求是用dacpac 文件来维护数据库(sql server project)
现在我要用powershell 来deploy 这个文件 databasename.dacpac
但是要执行这个需要用到Microsoft.SqlServer.Management.Dac.dll
照道理应该在C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies 下面,可是我机器上没有。。。
谁能知道怎么搞嘛,或者能告诉我怎么用powershell deploy文件 databasename.dacpac的方法
当前系统是sql server 2008 R2
PS: 在sql server 2012 已经实现
微软官方代码2008 R2
CD SQLSERVER:\SQL\localhost\DEFAULT
$srv = get-item .
## Open a Common.ServerConnection to the same instance.
$serverconnection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection($srv.ConnectionContext.SqlConnectionObject)
$serverconnection.Connect()
$dacstore = New-Object Microsoft.SqlServer.Management.
## Load the DAC package file.
$dacpacPath = "C:\MyDACs\MyApplication.dacpac"
$fileStream = [System.IO.File]::Open($dacpacPath,[System.IO.FileMode]::OpenOrCreate)
$dacType = [Microsoft.SqlServer.Management.Dac.DacType]::Load($fileStream)
## Subscribe to the DAC deployment events.
$dacstore.add_DacActionStarted({Write-Host `n`nStarting at $(get-date) :: $_.Description})
$dacstore.add_DacActionFinished({Write-Host Completed at $(get-date) :: $_.Description})
## Deploy the DAC and create the database.
$dacName = "MyApplication"
$evaluateTSPolicy = $true
$deployProperties = New-Object Microsoft.SqlServer.Management.Dac.DatabaseDeploymentProperties($serverconnection,$dacName)
$dacstore.Install($dacType, $deployProperties, $evaluateTSPolicy)
$fileStream.Close()