Temelie.Database.Services
1.0.205
See the version list below for details.
dotnet add package Temelie.Database.Services --version 1.0.205
NuGet\Install-Package Temelie.Database.Services -Version 1.0.205
<PackageReference Include="Temelie.Database.Services" Version="1.0.205" />
<PackageVersion Include="Temelie.Database.Services" Version="1.0.205" />
<PackageReference Include="Temelie.Database.Services" />
paket add Temelie.Database.Services --version 1.0.205
#r "nuget: Temelie.Database.Services, 1.0.205"
#:package Temelie.Database.Services@1.0.205
#addin nuget:?package=Temelie.Database.Services&version=1.0.205
#tool nuget:?package=Temelie.Database.Services&version=1.0.205
Temelie.Database.Services
Database-first tooling for reading schemas, scripting databases to source control, deploying those scripts, copying data between databases, and syncing changes.
dotnet add package Temelie.Database.Services
dotnet add package Temelie.Database.Providers.Mssql # and/or Temelie.Database.Providers.MySql
Services are exported with [Export...] attributes. Reference Temelie.DependencyInjection.SourceGenerator in your application to register them, along with the providers you reference.
Services
| Service | Purpose |
|---|---|
IScriptService |
CreateScripts scripts a database to a folder; ExecuteScripts deploys a folder to a database. |
IDatabaseModelService |
Reads a live database into a DatabaseModel, with optional DatabaseModelOptions filtering. |
IDatabaseExecutionService |
Creates connections and runs commands; ExecuteFile runs scripts split on GO. |
ITableConverterService |
Copies table data between databases or providers using bulk copy, in parallel. |
IChangeTrackingService |
Syncs incremental changes from a source database (SQL Server Change Tracking or CDC) to a target. |
IDatabaseFactory |
Resolves the IDatabaseProvider for a provider name or connection. |
Extension points
| Interface | Use |
|---|---|
IDatabaseProvider / DatabaseProviderBase |
Add a database engine. |
IDatabaseModelProvider |
Adjust models as they are read, for example to format SQL or rename objects (all Initialize methods are optional). |
IConnectionCreatedNotification |
Change connections before they open, for example to set an access token. |
ITableConverterReaderColumnValueProvider |
Transform values while copying tables. |
Scripting a database
var connection = new ConnectionStringModel
{
Name = "Dev",
DatabaseProviderName = "SqlConnection",
ConnectionString = "Data Source=.;Initial Catalog=MyApp;Integrated Security=True;Encrypt=False"
};
scriptService.CreateScripts(connection, new DirectoryInfo("src/MyApp.Database"), progress => Console.WriteLine(progress));
Every object is written as a .sql script plus a .sql.json model:
| Folder | Contents |
|---|---|
02_Tables |
Tables |
03_Indexes |
Primary keys and indexes |
04_CheckConstraints |
Check constraints |
05_Programmability |
Procedures and functions |
05_Views |
Views |
06_Triggers |
Triggers |
08_ForeignKeys |
Foreign keys |
09_SecurityPolicies |
Row-level security policies |
Generation details:
- File names are
schema.name.sql. - Unchanged files are left untouched, and files for objects that no longer exist are deleted.
- Column changes to an existing table are written as a dated migration,
04_Migrations/yyyy-MM-dd/01_<Table>.sql.
Deploying scripts
scriptService.ExecuteScripts(connection, new DirectoryInfo("src/MyApp.Database"), progress => Console.WriteLine(progress), continueOnError: true);
Top-level folders run in name order, which lets you interleave your own folders with the generated ones:
| Folder kind | Behavior |
|---|---|
Object folders (contain .sql.json) |
Compared with the live database; only differences are applied. Missing objects are created, changed objects are dropped and recreated, and removed objects are dropped. A table change also recreates procedures, functions, triggers, and views without indexes. Tables themselves are never recreated: change them with migrations. |
*_Migrations/<name>/*.sql |
Each file runs once, in order, and is recorded in a Migrations table (created automatically) with the id <folder>/<name>/<file>. With skipMigrations: true they are recorded without running, for example to baseline an existing database. |
*_Always/*.sql |
Run on every deployment. |
Other folders with only .sql files |
Each file runs on every deployment. |
More deployment details:
- Removed tables are renamed to
__<Table>instead of being dropped, so no data is lost. - Failures: with
continueOnError, failed non-migration scripts are collected, and the whole run is retried up to 5 times. This resolves most ordering problems between objects. A failed migration ends the current attempt immediately. WithoutcontinueOnError, the first failure stops the deployment. - Batches: scripts are split into batches on
GOlines.
A typical project layout:
MyApp.Database/
01_Always/ helper procedures used by migrations
02_Migrations/<date>/ data and schema changes that must run before objects are applied
02_Tables/ 03_Indexes/ 04_CheckConstraints/
04_Migrations/<date>/ table changes
05_Programmability/ 05_Views/ 06_Triggers/
07_Migrations/<date>/ data fixes that need the new views/procedures
08_ForeignKeys/ 09_SecurityPolicies/
09_Always/ post-deployment scripts
Generated .sql.json files can also feed Temelie.Entities.SourceGenerator.
Copying data
ITableConverterService.ConvertTables copies the selected tables from a source connection to a target connection. It matches columns by name, can trim strings, and uses provider bulk copy in batches, optionally inside a transaction.
Change sync
IChangeTrackingService reads changes from a source IChangeTrackingSourceProvider (mssql_ct or mssql_cdc) and applies them through an IChangeTrackingTargetProvider. It keeps the last synced version per mapping, so each sync only moves new changes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Azure.Identity (>= 1.21.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Temelie.Database.Models (>= 1.0.205)
- Temelie.DependencyInjection (>= 1.0.205)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Temelie.Database.Services:
| Package | Downloads |
|---|---|
|
Temelie.Database.Providers.MySql
Package Description |
|
|
Temelie.Database.Providers.Mssql
Package Description |
|
|
Temelie.Database.UI
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.207 | 43 | 11/7/2026 |
| 1.0.206 | 39 | 11/7/2026 |
| 1.0.205 | 41 | 11/7/2026 |
| 1.0.204 | 44 | 11/7/2026 |
| 1.0.202 | 4,019 | 10/13/2026 |
| 1.0.201 | 7,508 | 8/28/2026 |
| 1.0.200 | 216 | 8/26/2026 |
| 1.0.199 | 120 | 8/21/2026 |
| 1.0.196 | 83 | 8/21/2026 |
| 1.0.195 | 83 | 8/21/2026 |
| 1.0.194 | 2,034 | 8/19/2026 |
| 1.0.193 | 71 | 8/12/2026 |
| 1.0.192 | 21,709 | 7/21/2026 |
| 1.0.191 | 4,174 | 7/13/2026 |
| 1.0.190 | 1,024 | 7/9/2026 |
| 1.0.189 | 23,634 | 2/18/2026 |
| 1.0.188 | 80 | 2/13/2026 |
| 1.0.187 | 182 | 11/21/2025 |
| 1.0.186 | 4,759 | 11/20/2025 |
| 1.0.185 | 105 | 11/20/2025 |