'How do I fix SQL Server Database Project Ambiguous References?

I am having trouble getting Visual Studio 2022 (and 2017) to work with a simple Database Project. I have extracted a data tier application and stored it as a .dacpac file. I have added it as a database reference (Same server, different database.)

It is happy with this and can build and deploy it:

CREATE VIEW [dbo].[View1]
AS SELECT * FROM [$(CBS_ODS)].dbo.rm_acct

But this gives errors:

CREATE VIEW [dbo].[View1]
AS SELECT _IsCurrent FROM [$(CBS_ODS)].dbo.rm_acct

Specifically the two errors:

SQL71561: Computed Column: [dbo].[View1].[_IsCurrent] has an unresolved reference to object [$(CBS_ODS)].[dbo].[rm_acct].[_IsCurrent]
SQL71561: View: [dbo].[View1] has an unresolved reference to object [$(CBS_ODS)].[dbo].[rm_acct].[_IsCurrent]

At this point I've come to the conclusion that Database Projects are unusably buggy. Is there (a) any solution to this or (b) any way to turn of parsing/inspection entirely? It seems like the database references can see views, but not the columns in the views?



Solution 1:[1]

I think I've found the solution. Basically you need to add the database you're referring to as a reference, as well as all databases that reference refers to! ie. transitive references aren't automatic.

Pretty annoying as it means that the database reference isn't properly encapsulated from the user's point of view.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris KL