Nextended.Aspire.Hosting.DbTools
10.1.65
Prefix Reserved
dotnet add package Nextended.Aspire.Hosting.DbTools --version 10.1.65
NuGet\Install-Package Nextended.Aspire.Hosting.DbTools -Version 10.1.65
<PackageReference Include="Nextended.Aspire.Hosting.DbTools" Version="10.1.65" />
<PackageVersion Include="Nextended.Aspire.Hosting.DbTools" Version="10.1.65" />
<PackageReference Include="Nextended.Aspire.Hosting.DbTools" />
paket add Nextended.Aspire.Hosting.DbTools --version 10.1.65
#r "nuget: Nextended.Aspire.Hosting.DbTools, 10.1.65"
#:package Nextended.Aspire.Hosting.DbTools@10.1.65
#addin nuget:?package=Nextended.Aspire.Hosting.DbTools&version=10.1.65
#tool nuget:?package=Nextended.Aspire.Hosting.DbTools&version=10.1.65
![]()
Nextended.Aspire.Hosting.DbTools
Database tools for an Aspire app host. The first: fill a database resource from a database that already exists — schema and data — from another resource in the stack or from a server it does not model. PostgreSQL, SQL Server, MySQL/MariaDB, MongoDB and Redis, each through its own engine's dump and restore tools.
📖 Documentation: English · Deutsch | 🧪 Runnable sample: DbTools.AppHost
Database tools for an Aspire app host. The first one is cloning: filling a database resource from a database that already exists — schema and data, in one call.
var dev = builder.AddPostgres("pg");
// From a server this stack does not model
dev.AddDatabase("shop").WithCloneFrom("Host=staging.internal;Database=shop;Username=reader;Password=…");
// Or from another resource in it
dev.AddDatabase("shop-copy").WithCloneFrom(otherDatabase);
When it earns its place
Aspire creates empty databases, and WithCreationScript / WithInitFiles fill them from SQL you
wrote. That covers most stacks. This package is for the cases it does not:
- a development stack that needs the shapes and volumes of a real database, not a fixture,
- a new environment built out of an existing one,
- a copy of staging to run a migration against before running it for real.
If a seed script is enough for you, use the seed script.
Engines
Each is cloned with its own dump and restore tools, in a container of its own.
| Engine | How |
|---|---|
| PostgreSQL | pg_dump \| psql |
| MySQL / MariaDB | mysqldump \| mysql, routines and events included |
| SQL Server | BACPAC via sqlpackage |
| MongoDB | mongodump \| mongorestore |
| Redis | replication, then the target is cut loose again |
Where the source can come from
All four overloads exist for every engine, because a stack rarely has everything modelled.
target.WithCloneFrom(otherDatabase); // a resource in this stack
target.WithCloneFrom("Host=box;Database=shop;Username=u;Password=p"); // a connection string
target.WithCloneFrom("postgres://u:p@box:5432/shop"); // either form of one
target.WithCloneFrom(builder.AddParameter("staging", secret: true)); // where a password belongs
target.WithCloneFrom(builder.AddConnectionString("legacy")); // a string the stack was given
The last two are not known until the stack runs, so the string travels to the container and is taken
apart there — Host=/Server=/Data Source=, Username=/User Id=/Uid=, SQL Server's
Server=host,1433, and the scheme://user:pw@host:port/db form.
Options
target.WithCloneFrom(source, new DbCloneOptions
{
OnlyWhenEmpty = true, // the default: a target with something in it is left alone
Overwrite = false, // replace what is there — say it deliberately
SchemaOnly = false, // the shape without the rows
DataOnly = false, // the rows into a schema that exists
Image = null, // the image the dump runs in
Name = null, // what the clone is called in the dashboard
TimeoutSeconds = 3600,
});
SchemaOnly is refused for MongoDB and Redis when the app host is built rather than three minutes
later by a container: a collection is its documents and a key is its value. DataOnly is refused
for SQL Server for the same reason in reverse — a BACPAC is schema and rows in one file.
On SQL Server SchemaOnly is not the same clone with the rows left out; it is a different pair of
tools. /a:Extract and /a:Publish move a DACPAC, which takes minutes where a full export takes
hours, and can leave out what a container has no answer for: logins, permissions, external data
sources. That makes it the first thing to try against a database nobody has copied before — it says
within minutes whether the shape arrives at all. Nothing in that path drops anything: objects the
source does not have stay, and a publish that would have to rewrite a table stops instead.
Worth knowing
A cloned database still reports itself running while the copy is on its way. A database resource in Aspire has no state of its own — it cannot be made to wait for anything — so the clone container is what a stack waits for:
var copy = sql.AddDatabase("orders-copy").WithCloneFrom(staging);
builder.AddProject<Projects.Api>("api")
.WithReference(copy)
.WaitForCompletion(builder.CloneOf("orders-copy")); // starts when the copy is there
The clone's own resource is where its log is, and it says what it is doing while it does it: every line the dump and restore tools write, plus a heartbeat while a long one is quiet.
It runs where the stack runs. A clone is a container resource, not app-host code, so
aspire publish puts it in the manifest and a deployed stack clones too — which is the point when a
new system is built out of an old one. For a clone only while developing, wrap it yourself:
if (builder.ExecutionContext.IsRunMode)
dev.AddDatabase("shop").WithCloneFrom(staging);
SQL Server needs the internet the first time. sqlpackage is in no image, so the clone runs in
mcr.microsoft.com/dotnet/sdk:8.0 and installs it — half a minute, once per container start. An
air-gapped stack wants its own image: new DbCloneOptions { Image = "registry.internal/sqlpackage:1" }.
Overwrite there adds a …-clone-prepare container, because sqlpackage refuses to import into a
database that holds objects and dropping it needs a client from the server's own image.
Versions. A dump tool reads its own version and older, not newer. A source newer than the default
image needs Image set.
A clone copies the data as it is — real names, real addresses. Nothing here anonymises anything.
Sample
Tests/TestProjects/DbTools.AppHost
clones two databases — one from a server the stack does not model, one from a resource in it — and
opens both in a browser studio so the rows can be seen. dotnet run, and no table in that app host
is described by hand.
Supported frameworks
net8.0net9.0net10.0
Dependencies
- Aspire.Hosting.AppHost
- Aspire.Hosting.PostgreSQL
- Aspire.Hosting.SqlServer
- Aspire.Hosting.MySql
- Aspire.Hosting.MongoDB
- Aspire.Hosting.Redis
The Nextended family
The other 18 packages in the suite:
Core libraries
- Nextended.Core — Foundation library — extension methods, custom types (Money, Date, BaseId, SuperType), class mapping, deep clone, encryption, hashing and the code-generation attributes.
- Nextended.Cache — Expression-based caching — automatic cache keys from method expressions, CacheProvider with condition-based invalidation, thread-safe AddOrGetExisting.
Data access
- Nextended.EF — Entity Framework Core extensions — graph loading (LoadGraphAsync, IncludeAll, MultiInclude), declarative include definitions, paging, dynamic sorting and bulk operations.
ASP.NET Core & web
- Nextended.Web — ASP.NET Core utilities — zero-config OData (AddODataAuto), composable IQueryable OData appliers, strongly typed controller URLs, streaming download helpers and a background executor that can replay a captured request.
- Nextended.ResponseFilters — Fluent, provider-agnostic pipeline that redacts, masks, rounds, truncates, hashes, prunes and restructures response DTOs before serialization — per request, per user, per permission.
- Nextended.ResponseFilters.AspNetCore — ASP.NET Core adapter for Nextended.ResponseFilters — registers the pipeline as a global IAsyncResultFilter and replays structural edits against the serialized JSON tree.
UI libraries
- Nextended.Blazor — Blazor helpers — IBrowserFile extensions (bytes, data URLs, downloads), a hierarchical model for browsing inside uploaded zip/tar/rar archives, MIME-type detection and component-parameter reflection.
- Nextended.UI — WPF and Windows desktop helpers — a global input-binding manager with hold/sequence matching, DirectInput and XInput gamepad readers, key-bind capture controls, converters, behaviours, markup extensions and runtime-defined PropertyGrid types.
Code generation & tooling
- Nextended.Imaging — Image processing — aspect-preserving resize, crop, colour replacement, brightness-based foreground picking, thumbnail generation, byte/data-URL conversion and MIME detection from magic bytes.
- Nextended.CodeGen — Roslyn source generator — DTOs and interfaces from your entities, strongly typed classes from JSON/XML, lookup tables from Excel, documentation from source files, and TypeScript declarations of your contracts.
.NET Aspire hosting
- Nextended.Aspire — Conditional AppHost builder extensions — WithReferenceIf / WaitForIf / WithExplicitStartIf, strongly typed environment variables from config objects, HTTPS dev-cert wiring, Docker guards, GitHub-source resources and npm app discovery.
- Nextended.Aspire.Hosting.Supabase — The complete Supabase stack — Postgres, Auth (GoTrue), REST, Realtime, Storage, Studio, Kong and Edge Functions — as one composable Aspire resource.
- Nextended.Aspire.Hosting.N8n — The n8n workflow-automation platform as an Aspire resource, with Postgres persistence, workflow import and a typed client for triggering workflows from .NET.
- Nextended.Aspire.Hosting.Grafana — Grafana, Prometheus, Loki, Tempo, Promtail, cAdvisor, postgres_exporter and the OpenTelemetry Collector as composable resources with auto-provisioned datasources.
- Nextended.Aspire.Hosting.WebDataStudio — WebDataStudio — a browser database studio for PostgreSQL, MySQL, SQL Server, SQLite, Oracle, DuckDB, ClickHouse, MongoDB and Redis — wired to the databases of your stack, with accounts and roles, an optional SQL assistant, and an MCP endpoint for AI agents.
- Nextended.Aspire.Hosting.AspireUI — AspireUI — the visual AppHost builder — as a resource inside your own Aspire stack, with an optional pre-seeded admin user and a starter stack built from your project paths.
- Nextended.Aspire.Hosting.LocalAI — Self-hosted, OpenAI-compatible multimodal AI — image generation, text-to-speech, speech-to-text and video — with gallery model management, GPU support and Open WebUI.
- Nextended.Aspire.Hosting.Php — Run PHP endpoints inside your Aspire stack — a docroot folder or a single router script served by PHP's built-in web server, with php.ini settings as fluent options.
- Nextended.Aspire.Hosting.DbTools — Database tools for an Aspire app host. The first: fill a database resource from a database that already exists — schema and data — from another resource in the stack or from a server it does not model. PostgreSQL, SQL Server, MySQL/MariaDB, MongoDB and Redis, each through its own engine's dump and restore tools. (this package)
Links
- 📦 NuGet package
- 📖 Documentation — English
- 📖 Dokumentation — Deutsch
- 🏠 Documentation portal
- 🧪 Runnable sample
- 🧑💻 Source code
- 🐛 Report an issue
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- Aspire.Hosting.AppHost (>= 13.6.4)
- Aspire.Hosting.MongoDB (>= 13.6.4)
- Aspire.Hosting.MySql (>= 13.6.4)
- Aspire.Hosting.PostgreSQL (>= 13.6.4)
- Aspire.Hosting.Redis (>= 13.6.4)
- Aspire.Hosting.SqlServer (>= 13.6.4)
-
net8.0
- Aspire.Hosting.AppHost (>= 13.6.4)
- Aspire.Hosting.MongoDB (>= 13.6.4)
- Aspire.Hosting.MySql (>= 13.6.4)
- Aspire.Hosting.PostgreSQL (>= 13.6.4)
- Aspire.Hosting.Redis (>= 13.6.4)
- Aspire.Hosting.SqlServer (>= 13.6.4)
-
net9.0
- Aspire.Hosting.AppHost (>= 13.6.4)
- Aspire.Hosting.MongoDB (>= 13.6.4)
- Aspire.Hosting.MySql (>= 13.6.4)
- Aspire.Hosting.PostgreSQL (>= 13.6.4)
- Aspire.Hosting.Redis (>= 13.6.4)
- Aspire.Hosting.SqlServer (>= 13.6.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.65 | 45 | 11/14/2026 |
| 10.1.64 | 46 | 11/13/2026 |
| 10.1.63 | 53 | 11/12/2026 |
| 10.1.62 | 49 | 11/12/2026 |
| 10.1.61 | 44 | 11/12/2026 |
| 10.1.60 | 51 | 11/12/2026 |
| 10.1.59 | 47 | 11/12/2026 |
| 10.1.58 | 53 | 11/11/2026 |
| 10.1.57 | 51 | 11/11/2026 |
| 10.1.56 | 50 | 11/11/2026 |
| 10.1.55 | 49 | 11/11/2026 |
| 10.1.54 | 57 | 11/11/2026 |
| 10.1.53 | 91 | 11/8/2026 |
| 10.1.52 | 93 | 11/6/2026 |
| 10.1.51 | 92 | 11/5/2026 |
| 10.1.50 | 98 | 10/30/2026 |
| 10.1.49 | 103 | 10/29/2026 |
| 10.1.48 | 111 | 10/27/2026 |
| 10.1.47 | 102 | 10/25/2026 |
| 10.1.46 | 116 | 10/16/2026 |