0
votes

I have the situation where I'm working in a new database, built using a Visual Studio 2012 database project.

I have two database projects. e.g. "DB1" and "DB2".

DB1 have synonyms of objects from DB2 and 
DB2 have synonyms of objects from DB1.

when I imported both database in two different dbproject. its throwing errors for the objects where the synonyms are used.

i got to know from blogs that one way to solve is add database project reference. but in that case i am getting into problem that

if I refer "DB1" in "DB2" then I cant refer "DB2" in "DB1".

any help would be highly appreciated.

1
Did you read Defining Cross-Database References on MSDN - Pred
why use synonym in such way!? First refer why synonyms is used? and then use it in appropriate case only. Also one may refer old post - MarmiK
Marmik, that is in leagcy system which we cannot change currently. - Radhi
Pred, thanks for your post. it helped to explore blogs for my problems. and in the link sent by you it also talks about limitation of not able to add circular reference. - Radhi
I am having a similar problem in VS15 (2017). I have 4 DB projects. DB1 and DB2 use synonyms with the same name to point to a DB3 view. Works fine on the server, but the problem lies with Visual Studio not being able to interpret it. The DB1 synonym works in the stored procedures, but the DB2 view throws an error trying to reference the DB2 synonym. Changing a real world best practice to make VS happy seems rather like the tail wagging the dog does it not? - ARLibertarian

1 Answers

0
votes

found a blog where they said. there is no solution provided by microsoft for circular reference in dbproject.

The various workarounds suggested in MSDN forums far are far from ideal:

1) Creating a third DB project and include objects that require circular reference

2) Manage references using static .dbschema file

Source Blog