Unresolved Reference Error SQL71561 with SQL Server Data Tools 2010

谁说胖子不能爱 提交于 2020-07-18 06:46:25

问题


I am getting an error when using SSDT 2010 (latest updates, v10.3.21208.0) with multiple database projects in a single solution. The error reads the following:

SQL71561: View: [dbo].[View] has an unresolved reference to object [OtherDatabase].[dbo].[OtherTable]

I've read all the other resources I could find on Stack Overflow and Google. Here are some things I've already tried:

  • Setup Database References to the other projects within the solution.
  • Cleared out the Database variable option to bypass the SQLCLR variable that dynamically changes your database name based on configuration options.
  • Ensured that Enable extended Transact-SQL verification for common objects is disabled on all projects
  • Have the Database location option set to: Different database, same server
  • Ensured the Project Build Order is arranged logically
  • Tried the suggestions from this post

Nothing seems to be working for me. Any help would be much appreciated. Here is a screenshot that might shed more light on my problem:

Image showing my visual studio window with the error


回答1:


It has been a while, but I still want to share this solution with others that may be following the same lost links I was initially. Pay close attention to step 4. That cleared the issue for me.

A possible solution is to add a database reference to the database that has the missing object. The reference needs a Data-tier Application (dacpac file) that can be easily generated on the solution with the database project that has the missing object. Press the right mouse button over the database project and selected Snapshot Project. The dacpac file is created on the Snapshots folder. The file should then be copied to a common folder for re-usability.

In the project with the error press the right mouse button over the References and selected Add Database Reference. The Add Database Reference dialog appears:

  1. Select the dacpac file
  2. Select the database location. The most common option is "Different database, same server"
  3. Confirm that the Database name field is as expected
  4. Clear the "Database variable" field in the dialog. If this field has a value the queries must use this variable and not the database name



回答2:


If the referenced database project builds, but the reference isn't resolving, try cleaning and rebuilding the referenced project and cleaning the project doing the referencing.




回答3:


I'm using VS2015, but it might still apply. In my case, the referenced database had a "Database Variable Name" specified in the reference properties like $(SomeDb). If someone tried to refer to an item in the referenced database using the actual database name instead of the variable, we'd get a warning about an unresolved reference. Changing those to be like [$(SomeDb)].[dbo].[SomeTable] resolved the references.



来源:https://stackoverflow.com/questions/15438450/unresolved-reference-error-sql71561-with-sql-server-data-tools-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!