C# connection string to PostgreSQL Using Dapper

I have a C# application and needs to connect it postgresql using Dapper.

My Database name is Tournaments.

My connection string is shown below:

<add name="Tournaments" connectionString="Server=127.0.0.1;Port=5432);Database=Tournaments;Integrated Security=true;" providerName="PostgreSQL OLE DB Provider;"/>

The code to open is:

using (IDbConnection connection = new System.Data.OleDb.OleDbConnection(GlobalConfig.CnnString(db)))

During run I get the error

System.ArgumentException: 'An OLE DB Provider was not specified in the
ConnectionString. An example would be, 'Provider=SQLOLEDB;'.'

Why is the provider name i specified not being recognised ?

1 answer

Try to add "Provider=PostgreSQL OLE DB Provider;" to your connection string.

<add name="Tournaments" connectionString="Provider=PostgreSQL OLE DB Provider;Server=127.0.0.1;Port=5432;Database=Tournaments;Integrated Security=true;" providerName="PostgreSQL OLE DB Provider;"/>