# Use community extensions for SQL Server hosting

<Badge text="⭐ Community Toolkit" variant="tip" size="large" />

<Image
  src={sqlIcon}
  alt="SQL Server logo"
  width={100}
  height={100}
  class:list={'float-inline-left icon'}
  data-zoom-off
/>

The Aspire Community Toolkit SQL Server hosting extensions package provides extra functionality to the [Aspire.Hosting.SqlServer](https://www.nuget.org/packages/Aspire.Hosting.SqlServer) hosting package.

This package provides the following features:

- [Adminer](https://adminer.org/) management UI
- [DbGate](https://dbgate.org/) management UI

## Hosting integration

To get started with the Aspire Community Toolkit SQL Server hosting extensions, install the [CommunityToolkit.Aspire.Hosting.SqlServer.Extensions](https://www.nuget.org/packages/CommunityToolkit.Aspire.Hosting.SqlServer.Extensions) NuGet package in the AppHost project.

<InstallPackage packageName="CommunityToolkit.Aspire.Hosting.SqlServer.Extensions" />

For TypeScript AppHosts, add the Community Toolkit SQL Server extensions package to `aspire.config.json`:

```json title="aspire.config.json" ins={3}
{
  "packages": {
    "CommunityToolkit.Aspire.Hosting.SqlServer.Extensions": "*"
  }
}
```

## Add management UI

### DbGate management UI

To add the [DbGate](https://dbgate.org/) management UI to your SQL Server resource, call the `WithDbGate` method on the `SqlServerResourceBuilder` instance:

```csharp title="C# — AppHost.cs"
var builder = DistributedApplication.CreateBuilder(args);

var sqlserver = builder.AddSqlServer("sqlserver")
    .WithDbGate();

builder.AddProject<Projects.ExampleProject>("api")
    .WithReference(sqlserver);

builder.Build().Run();
```

```typescript title="TypeScript — apphost.mts"
import { createBuilder } from "./.aspire/modules/aspire.mjs";

const builder = await createBuilder();

const sqlserver = await builder.addSqlServer("sqlserver");
await sqlserver.withDbGate();

const api = await builder.addProject("api", "../Api/Api.csproj");
await api.withReference(sqlserver);

await builder.build().run();
```

This adds a new DbGate resource to the AppHost which is available from the Aspire dashboard. DbGate is a comprehensive database management tool that provides a web-based interface for managing your SQL Server databases.

### Adminer management UI

To add the [Adminer](https://adminer.org/) management UI to your SQL Server resource, call the `WithAdminer` method on the `SqlServerResourceBuilder` instance:

```csharp title="C# — AppHost.cs"
var builder = DistributedApplication.CreateBuilder(args);

var sqlserver = builder.AddSqlServer("sqlserver")
    .WithAdminer();

builder.AddProject<Projects.ExampleProject>("api")
    .WithReference(sqlserver);

builder.Build().Run();
```

```typescript title="TypeScript — apphost.mts"
import { createBuilder } from "./.aspire/modules/aspire.mjs";

const builder = await createBuilder();

const sqlserver = await builder.addSqlServer("sqlserver");
await sqlserver.withAdminer();

const api = await builder.addProject("api", "../Api/Api.csproj");
await api.withReference(sqlserver);

await builder.build().run();
```

This adds a new Adminer resource to the AppHost which is available from the Aspire dashboard. Adminer is a lightweight database management tool that provides a simple web interface for database operations.

### Using both management UIs

You can use both management UIs together on the same SQL Server resource:

```csharp title="C# — AppHost.cs"
var builder = DistributedApplication.CreateBuilder(args);

var sqlserver = builder.AddSqlServer("sqlserver")
    .WithDbGate()
    .WithAdminer();

builder.AddProject<Projects.ExampleProject>("api")
    .WithReference(sqlserver);

builder.Build().Run();
```

```typescript title="TypeScript — apphost.mts"
import { createBuilder } from "./.aspire/modules/aspire.mjs";

const builder = await createBuilder();

const sqlserver = await builder.addSqlServer("sqlserver");
await sqlserver.withDbGate();
await sqlserver.withAdminer();

const api = await builder.addProject("api", "../Api/Api.csproj");
await api.withReference(sqlserver);

await builder.build().run();
```

## See also

- [Adminer documentation](https://www.adminer.org/)
- [DbGate documentation](https://dbgate.org/)
- [SQL Server hosting integration](/integrations/databases/sql-server/sql-server-host/)
- [Connect to SQL Server](/integrations/databases/sql-server/sql-server-connect/)
- [Aspire Community Toolkit](https://github.com/CommunityToolkit/Aspire)
- [Aspire integrations overview](/integrations/overview/)
- [Aspire GitHub repo](https://github.com/microsoft/aspire)