Skip to content Skip to sidebar Skip to footer

Vs 2012 Database Project "unresolved Reference To Object" Error

I created SQL Server Database Project in VS 2012 & imported our database. When I build the project, I get a lot of 'unresolved reference to object' Errors. These errors are onl

Solution 1:

One other possibility is that the schema you have used in your view/table etc does not exist in the project. You may need to add the schema to the VS Database Project.

Right Click the project and Add > New Item > Schema

Solution 2:

I solved this issue.

It seems a few of my views/SPs have referenced the tables using this naming convention ( 3 parts qualified name ):

DatabaseName.SchemaName.TableName

I changed all references to be as the following:

SchemaName.TableName

Solution 3:

In my case, the function that couldn't be found was of Build Action=None and so it wasn't being included in the compile.

Changing the Build Action to Build corrected this.

Solution 4:

This happened to me when building a CTE in Visual Studio 2015. I changed the Build Action to Compile and the errors went away.

  1. Select the file(s) with the error
  2. Press F4 to see the properties.
  3. Select 'Compile' in the Build Action drop down list.

Hope this helps someone.

Solution 5:

To reference another sqlproj's schema and use three-part naming, modify your .sqlproj file to add a DatabaseVariableLiteralValue element on the referenced project.

In within the element like <ProjectReference Include="..\SomeDatabaseProject\SomeDatabaseProject.sqlproj">, add the following:

<DatabaseVariableLiteralValue>SomeDatabaseProject</DatabaseVariableLiteralValue>

For example:

<ProjectReferenceInclude="..\SomeDatabaseProject\SomeDatabaseProject.sqlproj"><Name>SomeDatabaseProject</Name><Project>{some-project-guid}</Project><Private>True</Private><DatabaseVariableLiteralValue>SomeDatabaseProject</DatabaseVariableLiteralValue></ProjectReference>

Then you can use clean, three-part naming references like SomeDatabaseProject.SomeSchema.SomeTable.

Post a Comment for "Vs 2012 Database Project "unresolved Reference To Object" Error"