builder.Services.AddDbContext<DEM_MASTERSContext>(options => options.UseSQLserver(builder.Configuration.GetConnectionString("Database")));
how to add connection string for pgadmin 4, above one is for sqlserver
pgadmin4
is not a database, Do you want to ask how to connect to PostgreSQL?
First, you need to add NuGet package:
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
Then, you need to add connectionstring
in appsettings.json
:
{
"ConnectionStrings": {
"WebApiDatabase": "Host=localhost; Database=xxx; Username=xxx; Password=xxx"
},
}
Finally configure it like this:
services.AddDbContext<xxxContext>(options =>
options.UseNpgsql(Configuration.GetConnectionString("ConnectionStrings")));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.