Npgsql.NpgsqlOperationInProgressException: A command is already in progress:
See original GitHub issueNpgsql.NpgsqlOperationInProgressException
I’ve updated from Npgsql 4.0.7 to 5.0.1.1 Project was in VS2017, now in VS2019
The issue
After updating Npgsql from 4.0.7 to 5.0.1.1 (as We have shifted from Visual Studio 2017 to 2019 thought, lets use the latest version) without changing any code Npgsql has started giving the exception. Npgsql.NpgsqlOperationInProgressException: A command is already in progress.
In previous version 4.0.7 it was working absolutely fine. What we were doing is using the same connection to perform multiple commands (sequentially / after first command completed). But this should not be the case for the connection even if I am performing multiple commands using separate Npgsql.Command A single connection should allow multiple commands as it was allowing till 4.0.7
Exception message: Npgsql.NpgsqlOperationInProgressException: A command is already in progress
Stack trace:
Further technical details
Npgsql version: 5.0.1.1 PostgreSQL version: 13.1 Operating system: Windows 10 Pro
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Npgsql 4.0.7 didn’t support multiple commands on the same connection either.
Some comments on your code above:
Am closing this as there’s nothing to do on the Npgsql side. I’d recommend thinking about what exactly you’re trying to do, and writing the database code more efficiently as a function of that.
and make sure to convert IQueriable to List, working with the elements in IQueriable will cause this issue as well.