Skip to content
DocsTry Aspire
DocsTry

Get started with SQL Database Projects

⭐ Community Toolkit SQL Database Projects icon

The SQL Database Projects hosting integration deploys a DACPAC to a SQL Server database as part of your Aspire AppHost. Use it to keep a database schema alongside the services that depend on it during local development and testing.

This is a hosting-only integration. Your AppHost models a SQL project resource and a target database. When the target database is ready, the integration publishes the DACPAC. The SQL project resource is a deployment task, not a connection resource; applications that need database access reference the SQL Server database directly.

architecture-beta
  group apphost(server)[AppHost]
  group app(server)[Application]

  service sqlproject(database)[SQL project resource] in apphost
  service database(database)[SQL Server database] in apphost
  service application(server)[App] in app

  sqlproject:R --> L:database
  database:R --> L:application

Install the Community Toolkit hosting package in the AppHost:

Terminal
aspire add CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects

Then add the SQL Server database and a SQL project resource. Update the DACPAC path to match your database project’s output.

apphost.mts
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const appHostDirectory = path.dirname(fileURLToPath(import.meta.url));
const dacpacPath = path.join(
appHostDirectory,
'../Database/bin/Debug/net10.0/Database.dacpac'
);
const sql = await builder.addSqlServer('sql');
const database = await sql.addDatabase('catalog');
const databaseProject = await builder.addSqlProject('catalog-schema');
await databaseProject.withDacpac(dacpacPath);
await databaseProject.withReference(database);
await builder.build().run();

For all resource APIs, deployment options, dashboard actions, and support for an existing SQL Server, see the hosting reference.

Configure SQL Database Projects in the AppHost