简体   繁体   中英

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. Please let me know if you can see any mistake I've made in my code.

web.config file

Error

The first error it shows is:

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.
See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.

And the second

PostgresException: 28P01: password authentication failed for user "u173082"

I think your property for the User Id is incorrect. 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."

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.

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