我正在使用 SSDT 数据库项目创建数据库并部署为 dacpac。 .NET 程序集是项目的一部分,在部署期间安装失败并显示以下错误消息:
CREATE ASSEMBLY for assembly 'xyz' failed because assembly 'xyz' is not authorized for PERMISSION_SET = UNSAFE. The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission.
dbo 是“sa”。我进入了项目属性并在杂项选项卡下选中了“可信赖”。但是,当我运行时,我仍然遇到错误
select name, is_trustworthy_on from sys.databases
我看到 is_trustworthy_on
是 0。看来这个设置没有效果。经过搜索,我发现了以下内容:
Some database options, such as TRUSTWORTHY, DB_CHAINING, and HONOR_BROKER_PRIORITY, cannot be adjusted as part of the deployment process.
来自 http://msdn.microsoft.com/en-us/library/ee210569.aspx
调整这个词对我来说意味着改变。这是一个新的数据库。但是,如果即使对于新数据库也是如此,为什么该设置存在于对话框中?我是否需要将其编写为预部署的一部分?
最佳答案
因为您已经选中了“杂项”选项卡中的“可信”复选框,所以您只需要确保选中了“部署数据库属性”选项(或设置为真)。此选项将位于不同的位置,具体取决于您的发布方式。一些地方包括:
- 转到“构建”菜单并选择“发布{项目名称}...”
- 出现“发布数据库”向导。
- 点击“高级...”按钮
- 顶部的复选框用于“部署数据库属性”
- 使用 SqlPackage.exe:
- 通过配置文件传入:
<ScriptDatabaseOptions>True</ScriptDatabaseOptions>
- 通过命令行传入:
/p:ScriptDatabaseOptions = True
- 通过配置文件传入:
- 将 MSDeploy 与 dbSqlPackage 提供程序一起使用:
- 选项是:
ScriptDatabaseOptions=True
- 选项是:
关于sql-server - 使用 dacpac 打开 TRUSTWORTHY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27236813/