dotnet / dotnet/efcore

Throw more specific error when attempting to leverage 'ExecuteUpdate/Delete' methods with InMemory provider

Open
#31,320 0 comments 2 reactions 0 assignees View on GitHub
area-in-memory customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

It is well documented that a lot of standard operations will not work properly with the InMemory provider. However, the exception that is thrown for some of those operations, particularly in this case the `ExecuteUpdate`/`ExecuteDelete` methods, makes it hard to tell that the issue is with the fact that the operation is not supported. The exception that is thrown today is the standard "query {x} could not be translated". This leads the developer into double/triple checking their C# query in search for something out of place, maybe some specific combination doesn't work, etc. However, no matter what the developer does, it will just never work because the methods themselves are just not supported at the core, regardless of the query it is being attached to.

I think it would help a lot if the framework could detect that the user is attempting to use a completely unsupported method and throw a more specific exception stating that fact more clearly. This would immediately steer the user away from using these instead of trying to fix something else in their queries that is not there.

If the exception message could mention specifically the method name(s), that would be ideal.

If there was something that could be done in a more general manner, that would be even better. Say, whenever a "cannot be translated" error was thrown, it would also tell "why" that wasn't possible, in this case here "because method X and method Y were not recognized" or something along those lines.

Related:
- https://github.com/dotnet/efcore/issues/30521

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.