I recently came across this error when attempting to build an SSDT solution that had been handed over to me by another developer. The database references within the solution were quite complicated for a couple of reasons:
- Due to the large number of objects in some of the databases, the solution included composite projects. This meant that a long-running build of all objects was not required for every deploy. The composite project was set up such that, for an example accounts database, the “old” objects (that had not changed for some time) were contained in the project Accounts-Base & the newly created objects were added to the project Accounts. A snapshot was taken of Accounts-Base & a Database Reference was added to Accounts pointing to the snapshot dacpac as the same database.
This meant that most of the time we only needed to build Accounts which contained a small number of new objects & Accounts-Base only needed to be built if the snapshot changed.
- Some of the projects referenced other projects within the solution to allow cross-database stored procedures to build correctly. For example, Accounts may reference LIB where LIB is a library of commonly used functions.
Another point of interest is that the Target Platform for the projects was changed from SQL Server 2008 to 2012. Although I don’t know that this contributed to the error, googling for the error number returned a number of results indicating that it occurs in solutions that have been upgraded to SSDT from an earlier version so it may be related. It is also possible that the solution had been upgraded in the past although I can’t verify this as I didn’t create the solution.
The error seems to have arisen because there were objects of the same name in Accounts & LIB. So, although the GetAccountId stored procedure in Accounts called the FormatId function in the same project, the fact that FormatId also existed in LIB was causing problems.
The solution I identified was to remove the database references & unload the project Accounts, delete the associated .dbmdl file (which I found in the same folder as Accounts.sqlproj) & reload the project. Then recreate the references. After this, the project built without errors.
Useful links: SSDT Database References: