SQL71562: Unresolved Reference to Object [$(dbVariable)].[sys].[objects] After Upgrading to VS 2022 (17.12) Pro

Jason Selburg 5 Reputation points
2024-11-19T14:50:36.1533333+00:00

A SQL Server Data Tools (SSDT) solution that has been used for several years includes multiple database projects, some referencing the master database and/or using [sys] tables in other referenced database projects within the same solution. This solution was configured with database references and functioned properly in VS 2019.

For example, the [MAIN_CODE] (db project) has stored procedures that reference [$(DATA01)].[sys].[tables] in the [DATA01] (db project) and/or [msdb].

After upgrading to VS 2022 Professional, the following error occurs: "71562: Unresolved reference to object [$(dbVariable)].[sys].[objects]." This error appears for all references to other database projects that refer to the [sys] schema, presumably those related to the [master] or [msdb] databases.

  • Attempts to resolve the issue, including removing and re-adding references, restarting Visual Studio and the PC, switching to INFORMATION_SCHEMA tables (which is not feasible due to references to [sys].[indexes]), and changing the target platform back to SQL 2019 with re-added references, have not been successful.
  • Additionally, creating a new .dacpac in the respective databases from a SQL 2022 server's [master] database and replacing it in the VS folder, as well as creating a new SSDT project named [master] and importing the existing .dacpac (which has encrypted/hidden object definitions), did not resolve the issue.

It appears that VS 2022 SSDT does not resolve projects' [sys] schema or objects correctly.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,228 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jason Selburg 5 Reputation points
    2024-11-20T21:38:46.7333333+00:00

    UPDATE: This issue appears to be resolved with the Update 17.12.1

    1 person found this answer helpful.

  2. Ki-lianK-7341 345 Reputation points
    2024-11-19T15:00:27.4866667+00:00
    1. Add Database Reference to Master:
      • Right-click References > Add Database Reference > System database > master.
    2. Check .sqlproj File:
      • Ensure the master database reference is correctly defined in your .sqlproj file.
    3. Update SSDT and Visual Studio:
      • Make sure both are up to date.
    4. Rebuild Solution:
      • Clean and rebuild your solution.
    5. Use Fully Qualified Names:
      • Ensure all system object references are fully qualified

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.