# 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/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions/PostgresBuilderExtensions.cs#L92-L102)

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>`)
  The Postgres server resource builder.
- `configureContainer` (`Action<IResourceBuilder<AdminerContainerResource>>`) `optional`
  Configuration callback for Adminer 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.

This overload is not available in polyglot app hosts. Use the overload without the configuration callback instead.

## Examples

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();
```

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## 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/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions/PostgresBuilderExtensions.cs#L44-L56)

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.

This overload is not available in polyglot app hosts. Use the overload without the configuration callback instead.

## 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();
```

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
