【发布时间】:2018-08-01 13:35:19
【问题描述】:
在我的 appsettings.json 中:
{
"Data": {
"DefaultConnection": {
"ConnectionString": "Host=localhost;Username={{postgres}};Password={{postgres}};Database={{asp_trial_api}};Port=5432;Pooling=true;"
}
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
在我的 startup.cs 中:
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddDbContext<WebAPIDataContext>(options => {
options.UseNpgsql(Configuration["Data:DefaultConnection:ConnectionString"]);
});
services.AddMvc();
services.AddSwaggerGen();
}
我的dotnet ef migrations add initial成功了,但是dotnet ef database update给了我以下错误:
28P01: password authentication failed for user "{{postgres}}"
我在连接字符串中提供的用户名和密码是正确的。我已经在我的 PostgresSQL 中创建了一个名为 asp_trial_api 的空白数据库。
这里出了什么问题?
【问题讨论】:
标签: asp.net-core asp.net-core-mvc entity-framework-core