A database project configured in Visual Studio will have database references to external and internal databases it requires. While I would strongly advise against crossing database boundaries using this mechanism, there are legacy systems that require this. Part of bringing those legacy databases into standard development and deployment patterns means setting up database projects and publish profiles.
For your own databases that is a trivial task, but what do you do when using the system metdata. Examples of these are sys.objects, sys. tables and more. These objects raise errors in the pattern “Object contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects”. Fortunately these are easy to resolve.The short answer is you need a reference to the master database.
- Right click on References in your database project and select “Add Database Reference”.
- Under Database Reference select the “System database” radio button.
- Select “master” from the drop down list.
- Click “OK”
When you do this the database will show under References as per the below.
Moreover, all your errors relating to this should have disappeared.