Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/community-toolkit/hosting-sql-database-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@ builder.AddSqlProject<Projects.MySqlProj>("mysqlproj")

Now when you run your .NET Aspire app host project you see the SQL Database Project being published to the specified SQL Server.

## NuGet Package support

Starting with version 9.2.0, you can deploy databases from referenced NuGet packages, such as those produced by [📦 MSBuild.Sdk.SqlProj](https://www.nuget.org/packages/MSBuild.Sdk.SqlProj) or [📦 Microsoft.Build.Sql](https://www.nuget.org/packages/Microsoft.Build.Sql). To deploy, add the NuGet package to your Aspire app host project, for example:

```dotnetcli
dotnet add package ErikEJ.Dacpac.Chinook
```

Next, edit your project file to set the `IsAspirePackageResource` flag to `True` for the corresponding `PackageReference`, as shown in the following example:

```xml
<PackageReference Include="ErikEJ.Dacpac.Chinook" Version="1.0.0"
IsAspirePackageResource="True" />
```

Finally, add the package as a resource to your app model:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var sql = builder.AddSqlServer("sql")
.AddDatabase("test");

builder.AddSqlPackage<Packages.ErikEJ_Dacpac_Chinook>("chinook")
.WithReference(sql);
```

> [!NOTE]
> By default, the _.dacpac_ is expected to be located under `tools/<package-id>.dacpac`. In the preceding example, the _tools/ErikEJ.Dacpac.Chinook.dacpac_ path is expected. If for whatever reason the _.dacpac_ is under a different path within the package you can use `WithDacpac("relative/path/to/some.dacpac")` API to specify a path relative to the root of app host project directory.

### Local .dacpac file support

If you are sourcing your _.dacpac_ file from somewhere other than a project reference, you can also specify the path to the _.dacpac_ file directly:
Expand Down
Loading