Query builder throws error when using ToListAsync in combination with EF Core DbSet
I'm writing a POC to see how viable F# is for our new project. I have set up an in memory database with EF Core, as I want to give the current developers some points of recognition while highlighting some interesting new ways of doing things. One of those things is to use a query builder. When I use my db.Drones to get all the drones and I call Seq.toList, it all works fine. When I instead use EntityFrameworkQueryableExtensions.ToListAsync I get the error InvalidOperationException: The source 'IQueryable' doesn't implement 'IAsyncEnumerable<Drone.Api.Features.GetDrones+DroneDto>'.
Working version:
query {
for drone in context.Drones do
select {
Make = drone.Make
Model = drone.Model
}
} |> Seq.toList
Version that throws error:
open Microsoft.EntityFrameworkCore
query {
for drone in context.Drones do
select {
Make = drone.Make
Model = drone.Model
}
} |> EntityFrameworkQueryableExtensions.ToListAsync
Expectation: A way to query my database in an async manner.
query doesn't support async enumeration by itself, it just returns IQueryable which contains the query.
It's hard to say what exactly is ToListAsync trying to do with it. This should probably be raised with @dotnet/efteam to clarify.