Skip to content

Disable automatic query client evaluation #14935

Closed
Closed

Description

@ajcvickers

This is planned for 3.0 anyway--see #12795. However, by disabling now for the next preview, we can start getting feedback on the break to prepare for when the 3.0 query changes are in a state to be shipped.

Activity

  1. self-assigned this
    on Mar 8, 2019
  2. modified the milestones: , 3.0.0 on Mar 8, 2019
  3. modified the milestones: 3.0.0, on Apr 15, 2019
  4. 27 remaining items

  5. peter-bozovic commented on Mar 25, 2020

    @peter-bozovic

    Got into issues with this breaking change while upgrading our project to 3.1

    Was able to fix most of the simpler queries with AsEnumerable(), but we have few places where the query is built dynamically.

    For example the user can choose many search parameters and then we build the query with AsQueryable() and depending on choices Where() and GroupBy() are selectivelly added to the query before we finally call ToList() to fetch the data:

    In this scenario we can't insert AsQueryable() in the middle of the query build chain as it's not IQueryable anymore ...

    I was happy with EF that was able to determine the best way to manage those requests and return me results. At the moment I can't imagine how I can do this manually and will probably end up in even worse performances because of the complexity and number of tables my dynamic query needs to handle ...

    Si I guess i'll have to stick with 2.2 until I find some solution or hopefuly client evaluations might come back as optional query paramater in some future EF version ...

  6. roji commented on Mar 26, 2020

    @roji
    Member

    @peter-bozovic note that there aren't any plans to bring back client evaluation at the moment. While the upgrade from 2.x to 3.x is indeed painful because of this, we believe that EF Core shouldn't be transparently pulling back an entire table because something couldn't be translated in a Where clause.

    If you want to dynamically add search parameters which would get evaluated on the client side, you can still do that by composing an IEnumerable expression tree and compiling that. But once again, you're the one who knows whether it makes sense for your users that you perform arbitrary queries in a potentially extremely-inefficient way (which is what 2.2 did for you).

  7. jjxtra commented on Mar 26, 2020

    @jjxtra

    Agreed, simply use ToArray/ToList and finish out the rest of your query after that.

  8. jgehlbach commented on Apr 16, 2020

    @jgehlbach

    We were also stuck in upgrading to EF Core 3 due to this issue.

    Is there any chance to get the QueryClientEvaluationWarnings out of a production system running 2.2 with a hint of where the problem occurs (e.g call stack)

    We could then run 2 weeks in production, fix all problematic code and then upgrade to 3.x with minimized chance of breaking.

    Maybe something supporting this kind of tracing can be implemented in a 2.2 patch if it's not possible out of the box.
    That would be great help for anyone migrating to 3.x

  9. MarkMcTernan commented on Jul 2, 2020

    @MarkMcTernan

    @darl0026 - You are the first one to ask a way to turn this off as evident by comments on this issue. We would consider a well-written PR with tests to add a way to client eval for all query operators in EF Core codebase if you would like to contribute.

    You must be kidding.

    This has got to be the worst example of premature optimization I've ever encountered in my professional career.

    You have broken thousands of advanced queries written by people that depended upon IQueryable's graceful degradation to IEnumerable up until 3.x. You can no longer use ternary operators on select projections, string concatenation, or complex select projections without intermediate stupidity like forcing evaluation & execution in the middle of the code. Hell, right now you can't even use functions like Contains or pass a predicate lambda via a method call to a where clause, so a client that expects to work on an IEnumerable (even if EF has already cached the result for Linq to Object manipulation) breaks when it gets an IQueryable expression that can no longer gracefully degrade to IEnumerable.

    Another example: Did you create a code first model with unmapped, calculated values to make queries simpler and less mistake prone, knowing that such things would be evaluated on the client after the full set (that matched a server side predicate) was pulled down? No more, now you must either explicitly force an evaluation via AsEnumerable() (or otherwise separate those two calls), or push the calculation into the server where clause. Elegant, code first calculated properties are now less valuable in 3.x than they were in 2.2. Why? to prevent a "mistake" that the developer fully intended? This was a major advantage of EF, now gone.

    So, let me summarize the upshot here:
    "We don't want junior developers to inadvertently write inefficient queries that could make EF look bad in some relatively rare circumstances which could readily be detected and improved once the performance degradation was noticed... so we are going to break backwards compatibility with the entire EF installed base and CORE PHILOSOPHY of IQueryable and break every application under the sun that uses advanced techniques that made EF worth adopting in the first place."

    This sucks. It was EF's flexibility and forgiving nature of accepting any valid LINQ expression for both data retrieval & client side data manipulation as it seamlessly toggled between LINQ to EF and LINQ to Objects that made it the best ORM available on ANY platform. EF's capabilities were the sort of thing you'd dangle in front of Java developers who didn't even know what they were missing over beers. Now we get to return to the world where 3NF querying concerns must be thought of as separate and distinct from OOP client manipulations.

    "We would consider a well-written PR with tests to add a way to client eval for all query operators in EF Core codebase if you would like to contribute."

    This is nearly the same tone and attitude expressed when the dotnet core System.Data team decided to remove the interfaces for IDbConnection/IDBTransaction, in their initial pass because the EF Core team thought abstract classes would be good enough. (thereby violating a core principle of SOLID). Of course MS eventually reversed themselves as the comments by reputable ORM developers shredding that decision piled up, but not before making all sorts of similar unhelpful statements.

    I know you're volunteers, but EF Core is an important project and platform for developers (especially commercial developers) everywhere, so let me put it this way, hopefully without being similarly dismissive:
    I get paid to code for a living and literally am pretty busy in life, so I don't have time to undo a devastating decision to break compatibility with every client written in EF Core up to this point and time."

    Nah. I'll just be sure to drop EF from the stack next time and go back to Dapper. Dapper's reliable. I thought EF was too, but evidently that is not the case anymore.

  10. smitpatel commented on Jul 2, 2020

    @smitpatel
    Contributor

    Core philosophy of IQueryable is not to evaluate anything rather build an expression tree to allow the query provider to process it whatever way they want. So we haven't broken core philosophy of IQueryable in any form. You may want to reconsider your understanding of IQueryable vs IEnumerable.

  11. MarkMcTernan commented on Jul 2, 2020

    @MarkMcTernan

    @darl0026 Not to sound blunt but then, don't upgrade to 3.0 if you're not ready / don't have the time to do so. Its a major version upgrade so breaking changes are to be expected. We're still on 2.2 for this exact reason and I don't think we will be upgrading for a while yet.

    EOL for 2.2 was 1 month after your comment.
    I've just spent the past week (while supposedly on vacation) porting 2.2 to 3.1 because Azure removed 2.2 from their stacks without warning around last weekend and the first warning I got (other than vague... "Hey, we're not going to support 2.2 any longer after December" was 500 errors from the App Service that then forced us to move to 3.0 only to discover the joys of EF Core's inexplicable abandonment of graceful degradation to LINQ to objects.

  12. MarkMcTernan commented on Jul 2, 2020

    @MarkMcTernan

    Core philosophy of IQueryable is not to evaluate anything rather build an expression tree to allow the query provider to process it whatever way they want. So we haven't broken core philosophy of IQueryable in any form. You may want to reconsider your understanding of IQueryable vs IEnumerable.

    1. That's a quite limited interpretation. Did someone in the dotnet core project empower the EF Core team to redefine IQueryable to NOT support graceful IEnumerable fallback because you guys thought it was problematic for EF? Because let me tell you, this decision, which flies in the face of EF from the very beginning, is very much problematic for EF. How does this breaking change not also violate the Liskoff substitution principle?

    2. I thought the purpose of EF Core was to build a superior ORM that provided efficiency via IQueryProvider based translation to any given ADO.Net backstore via LINQ, while simultaneously offering the performance and network efficiency of client side cached objects that could be manipulated via LINQ to Objects before being round tripped back to the datastore with minimal fuss. While there are some use cases (very large data sets with well distributed results), that were less optimal for EF, this usage pattern was highly optimal for the typical LOB app, since most apps aren't FB or Stack Overflow. You guys have chosen to optimize for an edge case that most people would have reached for another tool for, such as Dapper.

    3. You don't work for me nor do I pay you, but I am most definitely a customer of MS's offerings and platform. You are losing when you are arguing with a customer and tell them that they don't understand a product they have relied upon for years just because you have decided to make that product less useful than it was.

  13. dougiejay commented on Jul 3, 2020

    @dougiejay

    @MarkMcTernan I 100% agree with you. see my comments from Dec 2019. we STILL havent had capacity to move to 3.1x, over 8 months later. That is the reality of the breaking change in the real world for a large enterprise organisation.

  14. dougiejay commented on Jul 3, 2020

    @dougiejay

    @MarkMcTernan where have you had Azure removing 2.2? that terrifies me as we are still in production on 2.2.

  15. MarkMcTernan commented on Jul 3, 2020

    @MarkMcTernan

    If you look on the documentation for Azure's AppService, you'll see that 2.2 is not among the advertised frameworks.

    On June 19th, AzureDevOps removed 2.2 from their docker build agents on Mac, Linux, and Windows. This was announced here on June 1st:
    actions/runner-images#975
    [It strikers me as profoundly inadequate that AzureDevOps and Azure announce critical stuff with a Github post it note like this when I get missile launch code level communications every time the office 365 team wants to toggle a hosting option.]

    For me, the DevOps build agents broke first (I run xunit as part of the CD pipeline), but after fixing that I discovered it also applied to the App Service docker images themselves, because a successful deploy started throwing 500 errors for the same 'missing 2.2 framework' issue. The MS support rep confirmed for me that build agents and app services apparently rely upon the same cached Docker images.

    That was only a few days ago. I assumed it would be ok so long as I didn't run a deployment to my prod environment while I worked on the upgrade. That lasted a few days before my prod* App Service, which I never deployed to, started throwing 500 errors for the same reason, so apparently Azure attempted to spool up a running instance on a new container even though I had the "always on" feature set to true.

    *A caveat: My customer's "prod" is a dev/test B2 instance (B2 supports SSL, always on, and other 'prod' features). Maybe they won't touch the prod tier App Services, but I wouldn't bet on that after my experience.

  16. jjxtra commented on Jul 4, 2020

    @jjxtra

    I understand the frustration with the breaking changes here. I would have very much preferred a configuration property on the context options to opt into this new behavior, with the default being 2.2 behavior. I hope this is an option for .net 5. I also understand the maintenance burden of having two code paths or implementations so I don’t take this kind of request lightly.

  17. removed their assignment
    on Sep 1, 2024
  18. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions