Add the PostgreSQL database to the Host project

dotnet add package Aspire.Hosting.PostgreSQL
var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres");
var postgresdb = postgres.AddDatabase("postgresdb");

var exampleProject = builder.AddProject<Projects.ExampleProject>().WithReference(postgresdb);

Add PostgreSQL pgAdmin resource

var postgres = builder.AddPostgres("postgres").WithPgAdmin();

Add PostgreSQL pgWeb resource

var postgres = builder.AddPostgres("postgres").WithPgWeb();

Reference the PostgreSQL database in the final application

dotnet add package Aspire.Npgsql.EntityFrameworkCore.PostgreSQL
builder.AddNpgsqlDbContext<IdentityServiceDbContext>(connectionName: DbConstants.ConnectionStringName, configureDbContextOptions: options =>
{
    new NpgsqlDbContextOptionsBuilder(options).MigrationsHistoryTable(DbConstants.MigrationsHistoryTableName);
});