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

查看:20
本文介绍了使用 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 命名空间中,并且而不是使用 DacStoreDacExtractionUnit> 以前版本的类,大部分内容都已重构为全新的 DacServices 控制器类.(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!

推荐答案

刚收到微软的回复:

如您所见,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 位于 ma​​sters 数据库中,因为 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天全站免登陆