how to read multiple result of procedure in EF 6 as async
how to read multiple result of procedure in EF 6 as async
Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
Utpal Vishwas
21-May-2025In Entity Framework 6 (EF6) on .NET Framework, reading multiple result sets from a stored procedure asynchronously is not directly supported out of the box. EF6 supports
MultipleResultsonly via synchronous APIs. However, you can do it asynchronously by dropping down toDbContext.Database.SqlQueryandDbDataReader, usingExecuteReaderAsync.Goal
Call a stored procedure that returns multiple result sets, e.g.:
Solution: Use
DbCommand+ExecuteReaderAsyncHere’s a full example using ADO.NET with EF6 DbContext to read multiple result sets asynchronously.
Step-by-Step Example
Calling the Method
In your controller or service:
Explanation
DbContext.Database.ConnectionExecuteReaderAsync()DbDataReader.Translate<T>()NextResultAsync()Notes
Translate<T>()is only available in EF6 throughObjectContext.