UPDATE: This issue appears to be resolved with the Update 17.12.1
SQL71562: Unresolved Reference to Object [$(dbVariable)].[sys].[objects] After Upgrading to VS 2022 (17.12) Pro
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.
2 answers
Sort by: Most helpful
-
-
Kilian 345 Reputation points
2024-11-19T15:00:27.4866667+00:00 - Add Database Reference to Master:
- Right-click References > Add Database Reference > System database > master.
- Check .sqlproj File:
- Ensure the master database reference is correctly defined in your
.sqlproj
file.
- Ensure the master database reference is correctly defined in your
- Update SSDT and Visual Studio:
- Make sure both are up to date.
- Rebuild Solution:
- Clean and rebuild your solution.
- Use Fully Qualified Names:
- Ensure all system object references are fully qualified
- Add Database Reference to Master: