Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved Reference in Visual Studio 2012 Database Project

Is there a way to reference another database from my database project without directly referencing it?

For example, I want to be able to write something like this:

CREATE VIEW View1
AS
  SELECT X FROM OtherDB.dbo.Table1
like image 745
aron Avatar asked Nov 29 '25 05:11

aron


1 Answers

Your best bet is to add a database reference to your project. For VS2010 and lower DBProj files, you'll want to generate a dbschema file and add it as a database reference. For SSDT, you'll want to use a dacpac file. This works well for projects that are mostly static and you can even tailor them down to just include the objects that are relevant.

VS2010, 2008 - http://msdn.microsoft.com/en-us/library/dd193283%28v=VS.90%29.aspx has the documentation you'll need to export an existing database into a dbschema file. Place it somewhere your project can access it and add it as a "Database Reference".

SSDT - http://msdn.microsoft.com/en-us/library/hh550080%28v=VS.103%29.aspx gives you the command line reference for generating a dacpac file. Once generated, place it somewhere your project can access it and add as a database reference.

I've got a blog post on this for SSDT here: http://schottsql.blogspot.com/2012/10/ssdt-external-database-references.html

like image 157
Peter Schott Avatar answered Nov 30 '25 22:11

Peter Schott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!