通过SqlPackage.exe更新数据层应用程序版本

时间:2013-07-10 22:13:28

标签: sql command-line data-tier-applications dacpac

我目前正在通过命令行使用SqlPackage.exe 自动部署我的应用程序数据库,但无法找到更新我的数据层应用程序版本的方法

(发展,当然......)

http://msdn.microsoft.com/en-us/library/hh550080%28v=vs.103%29.aspx

我正在使用/ Action:Publish来推送我新构建的* .dacpac,但版本始终保持在v1.0.0.0,如果这不可能的话?如何更改ExtendedProperty?

我只想通过查看数据库来了解安装的版本。

任何想法?

2 个答案:

答案 0 :(得分:1)

Including

/p:RegisterDataTierApplication=true

as part of the command line is what worked for me to have SqlPackage.exe update the version stored in data-tier metadata with the version of the DACPAC being published.

In my testing, I've found that setting RegisterDataTierApplication to true is performing an upgrade if the target database is already registered. Essentially, this property tells SqlPackage.exe that the DACPAC should be published as a data-tier package, as opposed to just publishing any changed objects (and therefore causing drift).

So, the full command that I use is

SqlPackage.exe /a:publish /tcs:<target connection string> /sf:<DACPAC file path> /p:RegisterDataTierApplication=true /p:BlockWhenDriftDetected=false

(I found that I had to include /p:BlockWhenDriftDetected=false because SqlPackage.exe was returning an error that it detected drift, even though /a:deployreport did not report any drift.)

答案 1 :(得分:0)

在您的数据库项目上转到项目设置,有一个输出类型部分,单击“数据层应用程序(.dacpac)文件”下面的属性按钮:

在此对话框中,您可以设置随后部署的版本号,然后可以从以下位置查询此信息:

SELECT TOP 1000 [instance_id]
      ,[instance_name]
      ,[type_name]
      ,[type_version]
      ,[description]
      ,[type_stream]
      ,[date_created]
      ,[created_by]
      ,[database_name]
  FROM [msdb].[dbo].[sysdac_instances]