sql-servervisual-studioazure-devopssql-server-data-toolsdacpac

How can I add a database reference to another database on the same server without a .dacpac, so Visual Studio recognizes cross-database reference?


I am experiencing an unresolved reference error when I try to build my project because my project contains views that reference another database on the same server.

When I try to add a database reference, I am forced to select either a Data-tier Application (.dacpac), a System Database, or database project in the current solution.

Why I can't use these options:


Solution

  • The only way I know to do this is with including a dacpac for the other database. If it changes frequently, you could probably set up something on the post-build to automate copying it to the db project in which you're working, but unless the objects you're referencing change frequently, you really only need to update that file if the objects referenced change. For many cases, the core objects being referenced are likely pretty static so you can work on just pulling the latest dacpac when you need it or when something changes.