4

When deploying a SQL project with Visual Studio 2008 we create a .sql file.

In the project properties we have set the deploy action: Create a deployment script. When building and deploying the project the .sql is generated as expected. When inspecting the generated code I see the following SQL code:

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

Executing this piece of code will throw the following error.

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

Why is this code generated in the first place and how can I prevent this code to be generated? (As far as I know we don't have any SQLCLR stored procedures OR LINQ in the project)

1 Answer 1

2
+50

I'm not sure about VS2008, but in VS2012 There is an SQLCLR tab in Database Project Properties window. One of the options at the bottom of the page is check box labelled Generate DDL. If this is checked, uncheck it then build and generate the script again.

Third paragraph from How to: Work with CLR Database Objects states:

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

For more information on the SQLCLR options in Database Project Properties, see the MSDN article: http://msdn.microsoft.com/en-us/library/hh272681(v=vs.103).aspx#bkmk_sqlclr_sqlclrbuild

Sign up to request clarification or add additional context in comments.

7 Comments

Thank you for your answer. It sounds like the answer I'm looking for. When I'm back in the office I'll search for the check box and get back to you.
I've checked the project settings in Visual Studio 2008 but I can't find the option Generate DDL.
In the database project, under References is there any reference to System.Core? If so, remove it and try again.
There is no reference to System.Core.dll under References.
Another thought! Is the database server on which you are running the deployment script the same version as the database server listed under the Database Project Settings? I vaguely recall that CREATE ASSEMBLY is scripted for MSSQL 2005 but not for MSSQL 2008 because 2008 already includes the CLR dlls. So the problem may arise because your db project specifies 2005 and you are deploying to 2008.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.