SQLite Forum

Entity Framework Core created a query that does not return
Login
Apologies, I thought the download link would be available for anyone, I put the database file on [Google Drive](https://drive.google.com/file/d/1s3XTGVaJJdsPy6Yl9qI_o195LPb7QHku/view?usp=sharing) now.

> And, did it "return" before your rewrite?

Yes it did! I went back and checked out the generated SQL that worked, and it turns out EF split the query up into multiple separate queries that are much much smaller.

I also found a fix for the problem: I explicitly added [`.AsSplitQuery()`](https://docs.microsoft.com/en-us/ef/core/querying/single-split-queries) to the `IQueryable` and now the data are fetched in no time again.

> Is that the original EF-generated query? Or is it your rewrite?

I only fixed one `Id` on top that was passed in as a parameter and added a default return for a `Name` column I removed. Basically I trimmed the database as much as possible while still allowing the query to work.

>  It would be interesting to see how your "problem" fares with a more heavy-duty DBMS. Have you tried that?

I have the same database running on Sql Server, the generated query however uses `APPLY` and `UNION` operations there so it's not really comparable.

> Yes. It is either your fault for using EF Core way beyond its designed purpose

After reading through your post I think that I should change my code to use multiple separate calls instead of relying on EF to handle one large query. The `.AsSplitQuery()` works for now, but I will definitely change that.

Thank you for taking the time to write this up!