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
<PackageReference Include="Fdw.Schema.Database.Build" Version="1.7.0" />
<PackageVersion Include="Fdw.Schema.Database.Build" Version="1.7.0" />
<PackageReference Include="Fdw.Schema.Database.Build" />
paket add Fdw.Schema.Database.Build --version 1.7.0
#r "nuget: Fdw.Schema.Database.Build, 1.7.0"
#:package Fdw.Schema.Database.Build@1.7.0
#addin nuget:?package=Fdw.Schema.Database.Build&version=1.7.0
#tool nuget:?package=Fdw.Schema.Database.Build&version=1.7.0
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
.sqlfiles underdatabase\and abuildTransitiveprops file. The props file adds those files to theBuilditems of a database project (aMicrosoft.Build.Sqlproject) and adds the package id toFdwDatabasePackage. - 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,FdwCheckDatabasePackagesevaluates 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
FdwReportDatabasePackagesreturns@(FdwDatabasePackage)of the project that evaluates it.FdwCheckDatabasePackagesruns beforeBeforeBuildin a project that setsFdwHostProject.FdwAssemblePostDeployruns 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.
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 |