Search code examples
c#.netasp.net-coreado.netnpgsql

Error for AspNetCore 2.1 while opening NpgsqlConnection


I am facing issue with while opening the NpgsqlConnection in AspNet Core 2.1. It works correctly in AspNet Core 1.1. Following is the error thrown in AspNetCore 2.1

42501: permission denied to set restricted parameter "transaction_isolation"

Following is the code snippet

    using (IDbConnection dbConnection = new NpgsqlConnection(this._configuration["SpringData:ConnectionString"]))
        {
            try
            {   
                ///Error occurs while opening the connection
                dbConnection.Open();
            }
            catch
            {
            }
        }

Not sure how to debug it further and resolve it.

P.S. Issue started occuring after migrating to AspNetCore 2.1 from AspNetCore1.1


Solution

  • Issue got resolved after downgrading to Nuget package Npgsql.3.2.7. Earlier it was using Npgsql 4.0.3 which seems to have some issues.