Visual Studio 数据库项目中有没有办法在部署期间排除某些对象?

发布于 2024-09-12 07:31:54 字数 103 浏览 3 评论 0原文

我有一个场景,我使用 Visual Studio 2010 数据库项目将更改部署到多个数据库安装,但在某些数据库安装中,我想从该副本中排除一组视图。有没有办法使用构建配置来排除这些视图的部署?

I have a scenario where I am using a visual studio 2010 database project to deploy changes to multiple database installations, but on certain ones I want to exclude a set of views from that copy. Is there a way using build configurations to exclude these views from being deployed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深爱不及久伴 2024-09-19 07:31:54

我最终编写了一个自定义部署计划修改器,使用 sqlcmd 变量进行控制,指定在部署期间不应触及的对象。每个数据库项目配置可能引用一组不同的变量(.sqlcmdvars 文件) - 这可以在项目属性中的“部署”选项卡上设置。

计划修改器检查部署计划并删除创建/修改/删除应忽略的对象的步骤。我们使用它来忽略数据文件(在不同的暂存环境中具有不同的名称)、一些备份表和一些我们未保留在数据库项目中的对象类型(用户、角色成员资格、数据库级别权限)。该功能与架构比较配置(忽略对象类型)类似(但粒度更细),但它在部署期间工作(也适用于 VSDBCMD)。

“编写自定义部署计划修改器”部分听起来可能工作量很大,但实际上很简单,包括学习和测试部分,我花了不到一天的时间。 MSDN 上有一个非常有用的演练

I ended up writing a custom deployment plan modifier, controlled using sqlcmd variables specifying objects that should not be touched during deployment. Each database project configuration may reference a different set of those variables (a .sqlcmdvars file) - this can be set on the Deploy tab in the project properties.

The plan modifier inspects the deployment plan and deletes steps that create/modify/delete objects which should be ignored. We are using it to ignore data files (which have different names on various staging environments), some backup tables and a few types of objects we do not keep in the DB project (users, role memberships, database level permissions). The functionality is similar (but finer-grained) to Schema Comparison configuration (ignored object types), but it works during deployment (also with VSDBCMD).

The "write a custom deployment plan modifier" part may sound like a lot of work, but actually it is quite simple, it took me less than a day, including the learning and testing parts. There is a very helpful walkthrough on MSDN.

过期以后 2024-09-19 07:31:54

您是否尝试过创建复合项目?我自己还没有实现这个场景,但您似乎可以:

  1. 创建project1,其中包含所有部署所需的核心对象。
  2. 创建project2,其中包含某些部署所需的视图集。
  3. 在project2中添加对project1的引用。

因此,在部署project1时,将不包括视图,而在部署project2时,将包括视图和核心对象。

请查看以下 Microsoft 链接。特别是标题为“组合项目的使用和限制”的部分

http://msdn。 microsoft.com/en-us/library/dd193405.aspx

Have you tried creating a composite project? I haven't implemented this scenario myself but it would seem you could:

  1. Create project1 which consists of the core objects required for all deployments.
  2. Create project2 which consists of the set of views required for some deployments.
  3. Add a reference to project1 in project2.

Thus when deploying project1, the views would not be included and when deploying project2, the views as well as the core objects would be included.

Have a look at the following Microsoft link. In particular the section titled "Uses and Limitations of Composite Projects"

http://msdn.microsoft.com/en-us/library/dd193405.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文