# PostgresBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions](/reference/api/csharp/communitytoolkit.aspire.hosting.postgresql.extensions.md)
- Type: [PostgresBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.postgresql.extensions/postgresbuilderextensions.md)
- Kind: `Methods`
- Members: `2`

Provides extension methods for adding PostgreSQL resources to an `Hosting.IDistributedApplicationBuilder`.

## WithAdminer(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<AdminerContainerResource>>, string?)

- Name: `WithAdminer(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<AdminerContainerResource>>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<PostgresServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions/PostgresBuilderExtensions.cs#L82-L92)

Adds an administration and development platform for PostgreSQL to the application model using Adminer.

```csharp
public static class PostgresBuilderExtensions
{
    public static IResourceBuilder<PostgresServerResource> WithAdminer(
        this IResourceBuilder<PostgresServerResource> builder,
        Action<IResourceBuilder<AdminerContainerResource>>? configureContainer = null,
        string? containerName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<PostgresServerResource>`)
- `configureContainer` (`Action<IResourceBuilder<AdminerContainerResource>>`) `optional`
- `containerName` (`string?`) `optional`

## Returns

`IResourceBuilder<PostgresServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This version of the package defaults to the tag of the container image. The Postgres server resource builder. Configuration callback for Adminer container resource. The name of the container (Optional). Use in application host with a Postgres resource

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

var postgres = builder.AddPostgres("postgres")
   .WithAdminer();
var db = postgres.AddDatabase("db");

var api = builder.AddProject<Projects.Api>("api")
  .WithReference(db);

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

## WithDbGate(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<DbGateContainerResource>>, string?)

- Name: `WithDbGate(IResourceBuilder<PostgresServerResource>, Action<IResourceBuilder<DbGateContainerResource>>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<PostgresServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions/PostgresBuilderExtensions.cs#L40-L52)

Adds an administration and development platform for PostgreSQL to the application model using DbGate.

```csharp
public static class PostgresBuilderExtensions
{
    public static IResourceBuilder<PostgresServerResource> WithDbGate(
        this IResourceBuilder<PostgresServerResource> builder,
        Action<IResourceBuilder<DbGateContainerResource>>? configureContainer = null,
        string? containerName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<PostgresServerResource>`)
  The Postgres server resource builder.
- `configureContainer` (`Action<IResourceBuilder<DbGateContainerResource>>`) `optional`
  Configuration callback for DbGate container resource.
- `containerName` (`string?`) `optional`
  The name of the container (Optional).

## Returns

`IResourceBuilder<PostgresServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This version of the package defaults to the tag of the container image.

## Examples

Use in application host with a Postgres resource

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

var postgres = builder.AddPostgres("postgres")
   .WithDbGate();
var db = postgres.AddDatabase("db");

var api = builder.AddProject<Projects.Api>("api")
  .WithReference(db);

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