使用 SqlPackage.exe 发布 DACPAC 时防止删除用户 [英] Prevent dropping of users when publishing a DACPAC using SqlPackage.exe

查看:30
本文介绍了使用 SqlPackage.exe 发布 DACPAC 时防止删除用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 SqlPackage.exe 发布 DACPAC 时,是否有任何方法可以防止用户被删除,除了更改下面的设置,这可以防止所有不在 DACPAC 中的对象被删除.

Is there any way of preventing users being dropped when publishing a DACPAC using SqlPackage.exe, other than changing the setting below, which prevents all objects from being dropped if they're not in the DACPAC.

<DropObjectsNotInSource>True</DropObjectsNotInSource>

我们部署到多个环境中,每个环境都有不同的用户.当前的解决方法是:

We deploy to a number of environments, each with different users. Current workarounds are to either:

  1. 为每个环境编写用户脚本,以便在部署后重新创建他们
  2. 使用 /Action:Script 并手动更改部署脚本.
  1. Script the users for each environment to recreate them after deploying
  2. Use /Action:Script and manually change the deployment script.

虽然这些都不是理想的...

Neither of these are ideal though...

推荐答案

使用 SqlPackage.exe 参数(自 2015 年 2 月发布:新的高级发布选项,用于指定要排除或不删除的对象类型):

Use SqlPackage.exe parameters (since February 2015 release: New Advanced Publish Options to Specify Object Types to Exclude or Not Drop):

以下是我们在部署中使用的实际参数:

Here's the actual parameters we use in our deployment:

/p:DropObjectsNotInSource=True 
/p:ExcludeObjectTypes=Users;Logins;RoleMembership;Permissions

第一行清除了所有内容,但下一行进一步细化了不丢弃的内容.事实证明,这种组合对我们来说最有效,可以删除所有不必要的对象,同时保留登录映射原样.

The first line cleans all, but the next line further refines what not to drop. This combination proved the most effective with us to drop all unnecessary objects, yet retain the login mappings as they were.

可以从 MSDN - SqlPackage.exe

这篇关于使用 SqlPackage.exe 发布 DACPAC 时防止删除用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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