Skip to content

Aspire.Npgsql component does not create database #1170

@alexwolfmsft

Description

@alexwolfmsft

When providing a custom name for a database, the builder.AddPostgresContainer("pg").AddDatabase("postgresdb") methods do not seem to create the database in the Postgres container. For example, with the following code:

var postgresdb = builder.AddPostgresContainer("catalog").AddDatabase("catalogdb");

var postgres = builder.AddProject<Projects.AspireSQL>("aspirepostgres")
                       .WithReference(postgresdb);

And:

builder.AddNpgsqlDataSource("catalogdb");

I receive this error:
PostgresException: 3D000: database "catalogdb" does not exist

When I use psql commands in the container to view the list of databases, it looks like this:

image

Should I expect to see a "catalogdb" database listed here?

The connection and query does work if I switch to AddDatabase("postgres") to use the default database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-integrationsIssues pertaining to Aspire Integrations packagespostgresIssues related to Postgres integrations

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions