如何使DACPAC仅更新一种模式? [英] How to make DACPAC update only one schema?

查看:160
本文介绍了如何使DACPAC仅更新一种模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有* .sqlproj项目的VS2013解决方案,其中包含特定于此解决方案的对象.问题在于,这对于其他项目也是常见的数据库.

我的问题是将架构内的更改自动部署到数据库,而又不影响其他对象.默认情况下,DACPAC更新整个数据库(对于我而言是不需要的).

我试图编写部署贡献者 http://msdn.microsoft.com/zh-cn/library/dn268597(v=vs.103).aspx ,但似乎没有办法将其放在解决方案文件夹中,因为必须将其放置在Program中SQL Server的文件子文件夹.

我使用Bamboo来创建部署程序包,并且该应用程序托管在具有Azure SQL数据库的Microsoft Azure上.

有什么方法可以仅使用DACPAC或其他自动方法在数据库架构中部署数据库更改?

解决方案

您的两个选项如下:

  1. 将SqlPackage.exe和其他DAC DLL复制到解决方案中的一个文件夹中,或由部署团队控制的一个文件夹中.还将您的贡献者DLL复制到相同的文件夹中.然后确保在部署时从该位置使用SqlPackage.exe.由于将检查与Microsoft.Data.Tools.Schema.Sql.dll相同的文件夹中的所有DLL的扩展名,因此您可以使用此方法在部署过程中包括您的贡献者,而无需安装到系统范围的位置./p>

  2. 从dacpac过滤掉与其他架构相关的对象,然后使用DropObjectsNotInSource = false进行部署.这种方法不太理想,因为它不会删除要删除的对象,但是好处是您可以在构建时/在将其传递给部署团队之前进行操作.

请注意, API教程,并在示例项目中提供了一些示例.听起来您已经编写了选项#1(本教程的简化版本仅阻止添加,而不能更改/删除),但是您可以看到它们之间的比较.这些示例还展示了如何使用我们的API进行发布(这直接映射到使用SqlPackage.exe),以及如何轻松测试和验证贡献者的行为.

I have a VS2013 solution with *.sqlproj project that contains objects specific to this solution. The issue is that this is database common also for other projects.

My problem is to automatically deploy changes within my schema to database without affecting other objects. By default DACPAC updates whole database that is not desired in my case.

I tried to write deployment contributor http://msdn.microsoft.com/en-us/library/dn268597(v=vs.103).aspx but it seems there is no way to have it within solution folder, as it have to be placed in Program Files subfolder of SQL server.

I use Bamboo to create deployment packages and the application is hosted on Microsoft Azure with Azure SQL database.

Is there any way I can deploy DB changes only within my schema using DACPAC or other automatic means?

解决方案

Your two options are as follows:

  1. Copy SqlPackage.exe and the other DAC DLLs to a folder inside your solution, or one controlled by your deployment team. Also copy your contributor DLL to that same folder. Then make sure that when deploying you use SqlPackage.exe from that location. Since any DLL in the same folder as Microsoft.Data.Tools.Schema.Sql.dll will be checked for extensions you can use this method to get your contributor included during deployment, without the need to install to a system-wide location.

  2. Filter out objects related to other schemas from your dacpac, and then deploy with DropObjectsNotInSource = false. This is less ideal since it won't drop objects that you delete, but the benefit is that you can do it at build time / before passing to the deployment team.

Note that this basic topic is covered in the API tutorial I wrote, with some samples of that in this samples project. It sounds like you have option #1 written already (the tutorial has a simplified version that only blocks additions, not alters/drops), but you can see a comparison between them. Also the samples show how to publish using our APIs (this maps directly to using SqlPackage.exe) and how to easily test and validate contributor behavior.

这篇关于如何使DACPAC仅更新一种模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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