Exception message thrown by SingleAsync, when sequence contains no element, is vague
See original GitHub issueEntity Framework Core’s extension method SingleAsync
throws an exception, if more than one element exists. The message of this exception is vague and does not match with it’s synchronous LINQ counterpart Single
.
For comparison this is the message for the exception that is thrown by the Single
method.
System.InvalidOperationException: Sequence contains more than one matching element.
And here the exception message thrown by SingleAsync
, which doesn’t really tell us what the actual problem is:
System.InvalidOperationException: ‘Enumerator failed to MoveNextAsync.’
Expectation: The exception messages should be equal for both the synchronous and the asynchronous version.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:32
- Comments:13 (9 by maintainers)
Top Results From Across the Web
c# - Sequence contains no elements?
When you get the LINQ error "Sequence contains no elements", this is usually because you are using the First() or Single() command rather...
Read more >Sequence contains no elements, ERROR - Microsoft Q&A
it is an old Entity Framework application that I am trying to reconstruct and get running. Server Error in '/' Application. ... Description:...
Read more >[Solved] Sequence contains no elements(system. ...
Sequence contains no elements (system.invalidoperationexception: sequence contains no elements).
Read more >sequence contains no elements in c# sql - YouTube
How to solve sequence contains no elements in asp.net c# with sql. why show this error sequence contains no elements ...
Read more >Reliably testing code that adopts Swift Concurrency? - ...
I'm having a hard time figuring out how to test application code as it adopts async-await and begins to be scheduled concurrently.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ajcvickers The message returned is correct in ef core 2.2. This is only happening in ef core 3.0. The entire stack strace is changed. May be this should be considered a bug rather than enhancement.
The same happens with
FirstAsync
, when no element is returned.