You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our batching implementation currently uses NpgsqlCommand with legacy batching. Once dotnet/efcore#18990 is implemented, switch to using that (search for all suppressions of 618, obsolete API usage).
Reacted by jadu-1337, Vlad Ionescu and Sune Bøgh Fuglsang
Hi @roji , I was wondering if there’s any update on this issue—has work on switching to the new batching API started, or is there a rough timeline for when it might be addressed?
We're currently building our own EF Core provider on top of efcore.pg, and as part of that, we're replacing the IRelationalConnection service with our own implementation. While doing so, we noticed an explicit cast to NpgsqlDataReader in NpgsqlModificationCommandBatch, which is used to access the Statements property.
Since Statements is now marked obsolete with the note to use the new DbBatch API, we believe our issue might be resolved once this GitHub issue is completed.
Would there be any chance we could contribute to this effort? We'd be happy to help move it forward if that's possible.
Thanks again for your work and for considering our request!
If this is just about referencing the obsolete NpgsqlDataReader.Statements, then I'd recommend simply suppressing the warning as we do in NpgsqlModificationCommandBatch - that's just how things are at the moment. I'm definitely interested in having EF use DbBatch (not just for Npgsql/PG), but the obsoletion warning isn't really a strong reason for that (there are others).
Doing this probably won't be trivial. If you're interested in taking a stab at it, please take a look at the code first and post a quick proposal of what you intend to do before doing actual work and submitting a PR.
Thanks again for the clarification! I think there might have been a small misunderstanding—just to clarify, the warning itself isn’t an issue for us either.
The challenge we’re facing is with the explicit cast to NpgsqlDataReader in NpgsqlModificationCommandBatch. Since we’re replacing the underlying reader with our own implementation, this cast becomes problematic.
We were hoping that the switch to the new batching API might eliminate the need for that cast, and thus resolve our issue. But it’s possible we misunderstood the direction of the change.
Would you happen to know if the new batching API would indeed remove that dependency on NpgsqlDataReader, or if it’s likely to remain?
@yanw-bq the batching reader should indeed remove the cast to NpgsqlDataReader in that particular spot, but I can't say off the top of my mind whether there are others where specific features of NpgsqlDataReader (or NpgsqlConnection, or NpgsqlCommand...) are being used.
I don't know your reaosns for needing to replace NpgsqlDataReader, but as an alternative you may want to implement your special logic inside EF itself rather than inside NpgsqlDataReader (RelationalDataReader in EF is the wrapper around DbDataReader, and could be a better place to customize with your logic).
Just to clarify our situation a bit more: we're building a wrapper around NpgsqlConnection and NpgsqlDataReader, and we’d like our custom driver to remain compatible with efcore.pg. The issue we’re facing is that the explicit cast to NpgsqlDataReader in NpgsqlModificationCommandBatch attempts to cast our wrapper reader, which obviously fails.
We’re hoping that the transition to the new batching API might remove the need for that cast, but if not, we’d love to explore alternative approaches. We’re also interested in contributing to this issue and plan to put together a proposal once we have some time to dive deeper.
We’ll keep you updated—thanks again for your time and support!
Activity
yanw-bq commentedon Aug 1, 2025
Hi @roji , I was wondering if there’s any update on this issue—has work on switching to the new batching API started, or is there a rough timeline for when it might be addressed?
roji commentedon Aug 2, 2025
@yanw-bq what's you reason for asking, how specifically are you expecting this work to impact you?
yanw-bq commentedon Aug 7, 2025
Hi @roji,
Thanks for your earlier response!
We're currently building our own EF Core provider on top of efcore.pg, and as part of that, we're replacing the IRelationalConnection service with our own implementation. While doing so, we noticed an explicit cast to NpgsqlDataReader in NpgsqlModificationCommandBatch, which is used to access the Statements property.
Since Statements is now marked obsolete with the note to use the new DbBatch API, we believe our issue might be resolved once this GitHub issue is completed.
Would there be any chance we could contribute to this effort? We'd be happy to help move it forward if that's possible.
Thanks again for your work and for considering our request!
roji commentedon Aug 8, 2025
If this is just about referencing the obsolete NpgsqlDataReader.Statements, then I'd recommend simply suppressing the warning as we do in NpgsqlModificationCommandBatch - that's just how things are at the moment. I'm definitely interested in having EF use DbBatch (not just for Npgsql/PG), but the obsoletion warning isn't really a strong reason for that (there are others).
Doing this probably won't be trivial. If you're interested in taking a stab at it, please take a look at the code first and post a quick proposal of what you intend to do before doing actual work and submitting a PR.
yanw-bq commentedon Aug 14, 2025
Hi @roji,
Thanks again for the clarification! I think there might have been a small misunderstanding—just to clarify, the warning itself isn’t an issue for us either.
The challenge we’re facing is with the explicit cast to NpgsqlDataReader in NpgsqlModificationCommandBatch. Since we’re replacing the underlying reader with our own implementation, this cast becomes problematic.
We were hoping that the switch to the new batching API might eliminate the need for that cast, and thus resolve our issue. But it’s possible we misunderstood the direction of the change.
Would you happen to know if the new batching API would indeed remove that dependency on NpgsqlDataReader, or if it’s likely to remain?
Thanks again for your time and insights!
roji commentedon Aug 15, 2025
@yanw-bq the batching reader should indeed remove the cast to NpgsqlDataReader in that particular spot, but I can't say off the top of my mind whether there are others where specific features of NpgsqlDataReader (or NpgsqlConnection, or NpgsqlCommand...) are being used.
I don't know your reaosns for needing to replace NpgsqlDataReader, but as an alternative you may want to implement your special logic inside EF itself rather than inside NpgsqlDataReader (RelationalDataReader in EF is the wrapper around DbDataReader, and could be a better place to customize with your logic).
yanw-bq commentedon Aug 27, 2025
Hi @roji,
Thanks again for the continued discussion!
Just to clarify our situation a bit more: we're building a wrapper around NpgsqlConnection and NpgsqlDataReader, and we’d like our custom driver to remain compatible with efcore.pg. The issue we’re facing is that the explicit cast to NpgsqlDataReader in NpgsqlModificationCommandBatch attempts to cast our wrapper reader, which obviously fails.
We’re hoping that the transition to the new batching API might remove the need for that cast, but if not, we’d love to explore alternative approaches. We’re also interested in contributing to this issue and plan to put together a proposal once we have some time to dive deeper.
We’ll keep you updated—thanks again for your time and support!