dotnet / dotnet/fsharp

Query builder throws error when using ToListAsync in combination with EF Core DbSet

Open
#16,503 1 comment 0 reactions 0 assignees View on GitHub
Needs-More information
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

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'_.

Working version:
```fsharp
query {
for drone in context.Drones do
select {
Make = drone.Make
Model = drone.Model
}
} |> Seq.toList
```

Version that throws error:
```fsharp
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.