microsoft / microsoft/DacFx

Unable to use stubs to solve circular dependency issues

Open
#734 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
460
Forks
29
Avg merge
4d 9h
Merged PRs (30d)
7

Description

  • SqlPackage or DacFx Version: Microsoft.Build.Sql v2.0.0
  • .NET Framework (Windows-only) or .NET Core: dotnet core v9.0.308
  • Environment (local platform and source/target platforms): Win 11

Defining stubs is a common tactic proposed when dealing with circular dependencies between databases. This article directly suggest that it is also possible in SSDT, but provide no example repository. My attempt to accomplish this using SDK-style projects have not been successful. It is very likely that I have not setup the projects correctly, in which case I am glad to receive pointers. If I indeed have done everything correctly, one can assume that this is either a feature missing in SDK-style projects or a bug.

Steps to Reproduce:

  1. Define a stub-version of a database object in a project containing stubs for database Parent
  2. Reference the stub in a project containing real definitions for database Child
  3. Redefine the stub with its real implementation in a project containing real definitions for database Parent, that also references database Child.

To simplify, I've created an example repository to demonstrate the issue: https://github.com/johar-work/circular-references-stubs

Expected behavior:

  • All projects build successfully

Actual behavior:

  • Database project Parent (that redefine the stub) fails to build with Build error SQL71508: The model already has an element that has the same name ...

Did this occur in prior versions? If not - which version(s) did it work in?

  • Unknown

Additional details:

  • There are alternate solutions proposed to the issue of circular dependencies that might work better for SDK-style projects, but I have yet to investigate them all.
    • Composite projects (where database definitions are split over several projects until no circular references remain). This could be exponentially more complicated to setup and maintain.
    • Referencing dacpacs of other projects, instead of the projects directly. This has the downside of requiring a manual build order.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the johar-work/circular-references-stubs reproduction repository and the three-project sequence described in the issue. Build the Parent and Child projects using Microsoft.Build.Sql v2.0.0 on .NET 9.0.308, then trace the SQL71508 duplicate-element failure. Done means determining whether the setup exposes a bug or unsupported SDK-style behavior and documenting the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
build-system, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.