How to connect to an existing postgreSQL database in a new Blazor Server Web App?

60 views Asked by At

I try to scaffold DbContext using this line in package manager console:

Scaffold-DbContext "host=xx.xx.xx.xxx port=xxxx dbname=postgres user=xxxx password=xxxx sslmode=prefer connect_timeout=10 sslcert=<STORAGE_DIR>/.postgresql/postgresql.crt sslkey=<STORAGE_DIR>/.postgresql/postgresql.key" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Models

and i get this exeption:

System.Net.Sockets.SocketException (0x00002AF9) No such host known

i have installed the following packages first:

Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Tools
Npgsql.EntityFrameworkCore.PostgreSQL

Am i supposed to setup the connection string in appsettings.json first and add dbcontext to builder.Services before scaffolding?

0

There are 0 answers