Aller au contenu
DocsTry Aspire
DocsTry

Get started with SQL Database Projects

Ce contenu n’est pas encore disponible dans votre langue.

⭐ 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.cs
var builder = DistributedApplication.CreateBuilder(args);
var database = builder.AddSqlServer("sql")
.AddDatabase("catalog");
builder.AddSqlProject("catalog-schema")
.WithDacpac("../Database/bin/Debug/net10.0/Database.dacpac")
.WithReference(database);
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