79516454

Date: 2025-03-18 06:23:33
Score: 0.5
Natty:
Report link

As dear @JeffFritz's (Microsoft MVP) quote :

  1. The name of ConnectionString have to be same with the name that is specified in AppHost

  2. In ConnectionString name of Host have to be same with the name that is specified for container name (Postgres)

Now that works for both .Net Aspire and Docker

"ConnectionStrings": {
"MyDatabase":"Host=Postgres;Port=5432;Database=MyDatabase;Username=postgres;Password=postgrespassword;"
}
var postgres = builder
    .AddPostgres("Postgres", port: 5432)
    .AddDatabase("MyDatabase");
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @JeffFritz's
  • Self-answer (0.5):
Posted by: Arash.Zandi