Skip to content

Build error SQL71501: [….] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
elamathib opened this issue Apr 16, 2025 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@elamathib
Copy link

  • SqlPackage or DacFx Version: Microsoft.Build.Sql 1.0.0
  • .NET Framework (Windows-only) or .NET Core:9.0.102
  • Environment (local platform and source/target platforms): Microsoft Azure Synapse

Steps to Reproduce:

  1. Create a function with self join on a system view like INFORMATION_SCHEMA
  2. Perform dotnet build

Did this occur in prior versions? If not - which version(s) did it work in? no this is our first time onboarding to DACPAC

(DacFx/SqlPackage/SSMS/Azure Data Studio) DacFx

Build error SQL71501: [….] contains an unresolved reference to an object. Either the object does not exist or the reference is ambiguous

@elamathib elamathib added the bug Something isn't working label Apr 16, 2025
@dzsquared dzsquared added documentation Improvements or additions to documentation and removed bug Something isn't working labels Apr 18, 2025
@dzsquared dzsquared self-assigned this Apr 18, 2025
@dzsquared
Copy link
Contributor

Great question.
When you want to reference system objects you need to add a database reference to the "master dacpac" for the platform you're developing on. Since you're using the Microsoft.Build.Sql SDK, you can jump right to using a package reference. 🥳

If I understand correctly you're developing for Synapse dedicated pools, so the master dacpac package is published here: https://www.nuget.org/packages/Microsoft.SqlServer.Dacpacs.Synapse.Master

There's a couple ways to add this to your project (via the IDE, CLI, etc).

You can add it to the project in terminal with:

dotnet add package Microsoft.SqlServer.Dacpacs.Synapse.Master --version 130.2.5

Or you can directly edit your project file such that it contains the <PackageReference> element (probably end up looking something like this):

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build">
  <Sdk Name="Microsoft.Build.Sql" Version="1.0.0" />
  <PropertyGroup>
    <Name>SynapseWithRef</Name>
    <DSP>Microsoft.Data.Tools.Schema.Sql.SqlDwDatabaseSchemaProvider</DSP>
    <ModelCollation>1033, CI</ModelCollation>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.SqlServer.Dacpacs.Synapse.Master" Version="130.2.5" />
  </ItemGroup>
</Project>

At the moment the remainder of the system dacpacs are listed at the root of the repo, in case you need another one:

Image

Docs on package references: https://learn.microsoft.com/en-us/sql/tools/sql-database-projects/concepts/package-references?view=sql-server-ver16&pivots=sq1-command-line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants