I have an ASP.NET Core application in which I'm using EF Core with MSSQL. In one table of used db there's a column with around 2MB binary data values. Instead of materialising it in memory I'd like to stream that data to the user, so it won't end up in the LOH (Large Object Heap). I've found out that in order to do that I can use ADO.NET as it supports column values streaming.
Most of the time I'm perfectly happy with using EF Core, but in this one case I'd like to fallback to ADO.NET. I know EF Core nowadays depends on Microsoft.Data.Sql instead of System.Data.Sql, so when I found GetDbConnection() (provided in Microsoft.EntityFrameworkCore.Relational assembly) method I expected its return type to be Microsoft.Data.SqlClient.SqlConnection which would play nicely with Microsoft.Data.SqlClient.SqlCommand constructor, but in fact what I'm getting is System.Data.Common.DbConnection.
The question is it possible to transform System.Data.Common.DbConnection (which I'm getting from EF Core) into Microsoft.Data.SqlClient.SqlConnection (which I want to consume using Microsoft.Data.Sql)?