简体   繁体   English

使用 Npgsql 将 PostgreSQL 与 ASP.NET MVC 连接

[英]Connecting PostgreSQL with ASP.NET MVC using Npgsql

I'm attempting to connect my database to my ASP.NET MVC application but every time I start the application, I get an error saying that my password is incorrect which is impossible.我试图将我的数据库连接到我的 ASP.NET MVC 应用程序,但每次我启动应用程序时,我都会收到一条错误消息,说我的密码不正确,这是不可能的。 Please let me know if you can see any mistake I've made in my code.如果您能看到我在代码中犯的任何错误,请告诉我。

web.config file web.config 文件

Error错误

The first error it shows is:它显示的第一个错误是:

System.Data.Entity.Core.ProviderIncompatibleException: System.Data.Entity.Core.ProviderIncompatibleException:
'An error occurred accessing the database. '访问数据库时发生错误。 This usually means that the connection to the database failed.这通常意味着与数据库的连接失败。 Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file.检查连接字符串是否正确以及是否使用了适当的 DbContext 构造函数来指定它或在应用程序的配置文件中找到它。
See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections.有关 DbContext 和连接的信息,请参阅http://go.microsoft.com/fwlink/?LinkId=386386 See the inner exception for details of the failure.有关失败的详细信息,请参阅内部异常。

And the second第二个

PostgresException: 28P01: password authentication failed for user "u173082" PostgresException:28P01:用户“u173082”的密码认证失败

I think your property for the User Id is incorrect.我认为您的用户 ID 属性不正确。 I pulled a functional connection string, which looks like this:我拉了一个功能连接字符串,它看起来像这样:

Host=<>;Username=<>;Password=<>;Database=postgres;Port=5432

So, where you have "User Id" in your connection string, try using "Username."因此,如果您的连接字符串中有“用户 ID”,请尝试使用“用户名”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM