使用Visual Studio 2008部署SQL项目时出错

使用Visual Studio 2008部署SQL项目时,我们创建一个.sql文件.

在项目属性中,我们设置了部署操作:创建部署脚本.构建和部署项目时,会按预期生成.sql.检查生成的代码时,我看到以下SQL代码:

CREATE ASSEMBLY [System.Core]
AUTHORIZATION [dbo]
FROM 0x4D5A9….
WITH PERMISSION_SET = SAFE;

执行这段代码将引发以下错误.

CREATE ASSEMBLY failed because assembly ‘System.Core’ is a system assembly. Consider creating a user assembly to wrap desired functionality.

为什么首先生成此代码,如何防止生成此代码? (据我所知,我们在项目中没有任何SQLCLR存储过程或LINQ)

最佳答案 我不确定VS2008,但在VS2012中“数据库项目属性”窗口中有一个SQLCLR选项卡.页面底部的其中一个选项是标记为Generate DDL的复选框.如果选中此选项,请取消选中它,然后再次构建并生成脚本.

来自How to: Work with CLR Database Objects州的第三段:

The CLR and CLR Build property pages contain many settings for using
CLR database objects in your project. Specifically, the CLR property
page has a permission level setting to set permissions on the CLR
assembly. It also has the “Generate DDL” setting to control whether
DDL for the CLR database objects added to the project is generated.
The CLR Build property page contains all the compiler options that you
can set to configure the compilation of CLR code in the project. These
property pages can be accessed by right-clicking your project in
Solution Explorer and select Properties

有关数据库项目属性中的SQLCLR选项的详细信息,请参阅MSDN文章:http://msdn.microsoft.com/en-us/library/hh272681(v=vs.103).aspx#bkmk_sqlclr_sqlclrbuild

点赞