使用DACFx 3.0 API升级DACPAC-如何检查现有数据库的当前DAC版本? [英] Upgrading DACPACs with DACFx 3.0 API - How to inspect current DAC version of an existing database?

查看:175
本文介绍了使用DACFx 3.0 API升级DACPAC-如何检查现有数据库的当前DAC版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在重写团队的数据库部署Powershell脚本,以使用DACFx 3.0 API而不是2.0.我已经成功使用新的Microsoft.SqlServer.Dac.DacServices控制器类使DACPAC升级成功进行.

I am currently rewriting my team's database deployment Powershell script to use DACFx 3.0 API instead of 2.0. I've managed to get the DACPAC upgrade to work successfully, using the new Microsoft.SqlServer.Dac.DacServices controller class.

唯一的问题是:如何从现有数据库中获取当前的DACPAC版本号?

The only problem that remains is: how can I grab the current DACPAC version number off an existing database?

作为部署脚本的一部分,我们正在将其与要升级到的DACPAC版本进行比较,以确定是否有必要进行部署.这也用于确定是否运行与数据库相关的测试,因此,我们可以节省大量构建时间.

As part of our deployment script, we're comparing this to the DACPAC version that we are upgrading to, to determine whether a deployment is necessary. This is also used to decide whether to run the database-related tests, so this way we cut down a significant amount of time on our builds.

旧的DacFx2.0 API位于Microsoft.SqlServer.Management.Dac命名空间中,因此在旧的Powershell脚本中,我们仅通过数据库连接创建了DacStore对象,并从中获得了Version属性:

The old DacFx2.0 API lives in the Microsoft.SqlServer.Management.Dac namespace, so in the old Powershell script we simply created a DacStore object from the database connection and get the Version property off it:

我们的旧POWERSHELL脚本

$dacStore = New-Object Microsoft.SqlServer.Management.Dac.DacStore($serverConnection)
Write-Host "The following data-tier applications (instances) exist in the DAC store:"
foreach($dacInstance in $dacStore.DacInstances) 
{
    Write-Host Instance Name: $dacInstance.Name
    Write-Host DAC Type Application Name: $dacInstance.Type.Name
    Write-Host DAC Type Version: $dacInstance.Type.Version <--- **** this is what I need ****
}
...

该问题已在3.0中发布,该API位于Microsoft.SqlServer.Dac名称空间中,并且大多数内容都已重构为全新的DacServices,而不是使用以前版本的DacStoreDacExtractionUnit类.控制器类.( src ) "

The issue now in 3.0, the API lives in the Microsoft.SqlServer.Dac namespace, and "Instead of using the DacStore and DacExtractionUnit classes from previous versions, most everything has been refactored into the all-new DacServices controller class. (src)"

我还不能在DacServices类中找到等效的DacStore,所以截至目前,我还不知道如何检索当前的DAC版本.我尝试搜索MSDN文档,但它们的所有Powershell部分仍引用旧的DACFx2.0 API. (例如:此处).

I haven't been able to find an equivalent of DacStore in the DacServices class yet, so as of right now I don't know how to retrieve the current DAC version. I've tried searching through MSDN documentations but all their Powershell sections still referenced the old DACFx2.0 API. (example: here).

如果有人可以帮助我,将不胜感激.谢谢!

If anyone could help me that would be greatly appreciated. Thanks!

推荐答案

刚刚得到MSFT的回复:

Just got a reply from MSFT:

您发现的Dac 3.0 API没有此功能.使用T-SQL直接从dbo.sysdac_instances中选择此数据.

The Dac 3.0 API doesn't have this capability as you've discovered. Use T-SQL to select this data directly from dbo.sysdac_instances.

似乎这实际上是唯一的方法: http://msdn .microsoft.com/en-us/library/ee240830.aspx 因此,我现在将查询该视图,尽管我真的很想在某个时候将其引入DACFx API.请注意,视图 dbo.sysdac_instances 位于 masters 数据库中,因为SQL Azure中不存在msdb.

It seems like it is in fact the only way: http://msdn.microsoft.com/en-us/library/ee240830.aspx So I'll query off that view for now, although I'd really love to see it brought into the DACFx API at some point. Note that the view dbo.sysdac_instances is in the masters database, as msdb does not exist in SQL Azure.

这篇关于使用DACFx 3.0 API升级DACPAC-如何检查现有数据库的当前DAC版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆