1.添加引用
PM> Install-Package Npgsql.EntityFrameworkCore.PostgreSQL
PM> Install-Package Npgsql.EntityFrameworkCore.PostgreSQL.Design
PM> Install-Package Microsoft.EntityFrameworkCore.Tools
2.配置文件添加连接字符串
{
"ConnectionStrings": {
"PostgreSql": "User ID=postgres;Password=123456;Host=localhost;Port=5432;Database=AddressMatch_db"
},
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}
3.启动文件startup.cs 添加配置
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<AppSettings>