Dan Esparza
Dan Esparza

Reputation: 28385

VS2012: Database reference

As a C# developer, I'm familiar with adding assembly references in a Visual Studio project. It looks like you can also add a database reference to a project.

My question is: Why would you want to add a database reference to a project?

Does this let you do something special like track dependencies on database tables or columns?

Upvotes: 2

Views: 1090

Answers (2)

Kevin Cunnane
Kevin Cunnane

Reputation: 8110

For SSDT projects such as you mentioned, there are two main use cases for database references:

  • Composite projects are a great way to handle cases where you have common schema elements such as tables that are shared by a number of databases. This maps to the concept of inheritance and object reuse in C#, and helps you avoid duplicate code and improve your design.
  • External database references are used when your code such as sprocs and views needs to reference elements from other databases. It is useful in resolving references and ensuring the project can build successfully. In this case it maps pretty directly to the concept of referencing Apis in C#.

Note that the help you linked to is the old help for VS2010 projects, more accurate help for SSDT is here.

Also you might notice that you can also add references to .Net assemblies, that may be necessary if you are writing SQL CLR code in your project and need to reference external code.

Upvotes: 1

snacky
snacky

Reputation: 819

You cannot add a reference to a database project. The page you linked describes adding a reference to a database in a database project. The reference allows you to run scripts against the database within the project.

Upvotes: 1

Related Questions