4

I have two database. One database accesses tables in the other, via SYNONYMs. I have imported both databases into two separate projects in my solution.

But when I build, I get an error:

Error SQL71501: Computed Column: [dbo].[AccountBase].[AccountCategoryCode] has an unresolved reference to object [CRM].[AccountBase].[AccountCategoryCode].

[CRM].[AccountBase] is a SYNONYM pointing to the other database.

So, I created a Database Reference, and modified the SYNONYM to point at the other project, and got a reference called $(CRM). I then modified the SYNONYM to use that reference.

But I am still getting the same error. Is it possible to achieve what I am trying to do? That is, import the two projects, and have them compile in the database project, using the database reference to point to the database?

Craig
  • 18,074
  • 38
  • 147
  • 248
  • 1
    When you added the database reference did you set it to Same Server, different database with a variable for the name or did you leave the name empty? If you leave the variable name empty, you shouldn't need to try to use the $(CRM) for the reference because it will be hard-coded to whatever name you put in place for the reference. At that point, the synonym should work. I did a quick test on a local project and had no issues. You can also build a dacpac from the "reference" database and use that dacpac as the DB reference for the DB using synonyms. – Peter Schott May 05 '17 at 22:43
  • I'm still facing this error in Visual Studio 2019. Any answers would be appreciated. – Ajay Meda Mar 15 '22 at 23:43

0 Answers0