Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tSQLt projects fail to build in Visual Studio 2012

I have a number of database projects using tSQLt that build correctly in Visual Studio 2010. When I open them in Visual Studio 2012, I'm informed that the IDE has to make "functional changes" in order to use them.

Once I let the conversion go through, none of the database projects build successfully anymore. Instead, it seems like ever object in the tSQLt schema raises an error about sys.objects that looks like this:

{Path}.Database.Messages\Schema Objects\Schemas\tSQLt\
Programmability\Functions\Private_GetConstraintType.function.sql(6,10):
Error:  SQL71501: Function: [tSQLt].[Private_GetConstraintType] has an 
unresolved reference to object [sys].[objects].

The conversion doesn't appear to have changed the named scripts in any way. What's going on? (And how do I investigate a problem like this. It's pretty cryptic.)

like image 527
Yes - that Jake. Avatar asked Nov 28 '25 12:11

Yes - that Jake.


1 Answers

tSQLt function [tSQLt].[Private_GetConstraintType] selects from sys.objects which is located in msdb system database.

You need to add database reference to msdb (or master) database to your Database Project in the Visual Studio 2012 (Data Tools).

To do this go to the Solution->Project->Reference->Add Database Reference (see screenshot below)

enter image description here

and add reference to the system database msdb. This should help.

enter image description here

like image 98
Andrey Morozov Avatar answered Dec 01 '25 14:12

Andrey Morozov