I have a SQL Server CLR trigger project that was created in VS2008. Opening the project in VS2012 does not present any problem, but on build of the solution, I get SQL71501 errors, with Trigger: [...] has an unresolved reference to object [...].
Based on my reading, this is due to a missing database reference in the project. When I try to add a database reference, I get the Add Database Reference dialog that gives me three options:
Further reading suggested that the reason there are no database projects to select for the first option, is because no Data Connections have been added via the Server Explorer. In my case there are certainly Data Connections present, and while my project is open, I can quite happily browse the database, look at data etc.
I thought it might have something to do with the Target Framework, so I have tried targeting 3.5 and even 2, but the same problem occurs.
I feel like I'm missing something fundamental, but just can't quite work it out. Any help would be GREATLY appreciated.
In Solution Explorer, right click References and select Add Database Reference. Select the source of the database you are referencing (a project in the solution or a DACPAC). In the Add Database Reference dialog box, specify the Database Location as Same database. Copy the example usage and paste it into your .
You can create a new project in visual studio and select 'SQL Server' in the left hand menu. Fill in the project name and location as usual. In your newly created database project, select Project, Import, Database. The import database window will open, set up your existing database in here and press start.
I've seen this dialog not enable the 'OK' button because the Database Variable that it defaults is invalid (in my case it had a '.' in it).
The clue to this being the error is that the text in the 'Example Usage' field contains the error message - it's just hard to see as it's dark grey on light grey.
Editing the Database Variable name fixes this.
I found a workarroud for this, isn't optimal but at least it works:
try this - open sql server object explorer - create a new connection to your server - right click on the database and select create new the project... - the wizard will create the project with all the references and connection string attached to it.
cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With