Fdw.Schema.Database.Build 1.7.0

dotnet add package Fdw.Schema.Database.Build --version 1.7.0
                    
NuGet\Install-Package Fdw.Schema.Database.Build -Version 1.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fdw.Schema.Database.Build" Version="1.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fdw.Schema.Database.Build" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Fdw.Schema.Database.Build" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fdw.Schema.Database.Build --version 1.7.0
                    
#r "nuget: Fdw.Schema.Database.Build, 1.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Fdw.Schema.Database.Build@1.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fdw.Schema.Database.Build&version=1.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Fdw.Schema.Database.Build&version=1.7.0
                    
Install as a Cake Tool

Fdw.Schema.Database.Build

MSBuild files that keep a host's database project in step with the host. A package of build files only; it ships no assembly.

How a database comes from packages

  • A package that owns database tables ships its .sql files under database\ and a buildTransitive props file. The props file adds those files to the Build items of a database project (a Microsoft.Build.Sql project) and adds the package id to FdwDatabasePackage.
  • A host's database project references the same packages, takes only their build files (IncludeAssets="build;buildTransitive", PrivateAssets="all"), and builds one dacpac from every package's files. No composite merge at publish time.
  • The database project states its host with <FdwHostProject Include="path\to\Host.csproj" />. Before the model is built, FdwCheckDatabasePackages evaluates the host and compares the two sets of packages.

Diagnostics

Code Meaning
FDWDB001 The host reports no packages that ship database tables (usually it is not restored)
FDWDB002 The host references a package that ships database tables and the database project does not
FDWDB003 The database project references a package that ships database tables and the host does not
FDWDB004 The database project has a PostDeploy script of its own while packages ship post-deployment fragments: add it to FdwPostDeploy instead

Conditional foreign keys

When a table's foreign key points at a package the table's own package does not reference, the table is shipped without that constraint (it is listed in scripts/ownership/conditional-foreign-keys.json in the databases repo). The package ships a fragment under postdeploy\ and adds it to FdwPostDeploy in its props file (<FdwPostDeploy Include="$(MSBuildThisFileDirectory)..\postdeploy\*.sql" />). The fragment is guarded and does not depend on the order of the others:

IF OBJECT_ID(N'sched.ScheduleTag', N'U') IS NOT NULL
   AND OBJECT_ID(N'sched.Schedule', N'U') IS NOT NULL
   AND NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE name = N'FK_ScheduleTag_Schedule' AND parent_object_id = OBJECT_ID(N'sched.ScheduleTag'))
    EXEC (N'ALTER TABLE sched.ScheduleTag ADD CONSTRAINT FK_ScheduleTag_Schedule FOREIGN KEY (ScheduleId) REFERENCES sched.Schedule (Id)');

FdwAssemblePostDeploy builds the database project's one post-deployment script from the fragments of every package it references, so adding a package adds its fragments. When a table is missing, the constraint is not added and nothing fails. A second incremental publish of the same dacpac drops the constraint (it is not in the model) and the script adds it again, so the end state is right; databases are normally rebuilt (proven by scripts/tests/database-packages/publish-conditional.sh in the databases repo).

Targets

  • FdwReportDatabasePackages returns @(FdwDatabasePackage) of the project that evaluates it.
  • FdwCheckDatabasePackages runs before BeforeBuild in a project that sets FdwHostProject.
  • FdwAssemblePostDeploy runs before the model is built in a database project that references a package with post-deployment fragments.

Part of FractalDataWorks. Licensed under Apache-2.0.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Fdw.Schema.Database.Build:

Package Downloads
Fdw.Services.Notifications

Development tools and utilities for the Fdw ecosystem.

Fdw.Services.Multitenancy.Database

Development tools and utilities for the Fdw ecosystem.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.0 645 12/1/2026