Tuesday, January 26, 2016

Entity Framework Async: The source IQueryable doesn't implement IDbAsyncEnumerable<>

While investigating an Entity Framework issue, I stumbled over the following exception

The source IQueryable doesn't implement IDbAsyncEnumerable<VLM.PlattelandsLoket.Domain.Views.Codes.CodeValueView>. Only sources that implement IDbAsyncEnumerable can be used for Entity Framework asynchronous operations. For more details see http://go.microsoft.com/fwlink/?LinkId=287068.


What’s causing this error?

Entity Framework 6 introduced async support through a set of extension methods. These extension methods are defined on IQueryable and IEnumerable but actually expect an IDbAsyncEnumerable implementation behind the scenes  to work. When you try to use one of these extension methods on a LINQ query that isn’t an Entity Framework query, you end up with the error message above.

I have to say I’m not a big fan of this approach, it sounds like a ‘leaky abstraction’ to me.

What do you think? Code smell or not?

No comments: