You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you pass a method a cancellation token, you expect to catch OperationCanceledException (the base class of TaskCanceledException), not EntityCommandExecutionException with an InnerException of OperationCanceledException.
It's undesirable to have to catch both EntityCommandExecutionException and OperationCanceledException at all levels of the application because you don't know which it will be. It's an implementation detail leaking out.
System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while reading from the store provider's data
reader. See the inner exception for details. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.<StoreReadAsync>d__0.MoveNext()
--- End of inner exception stack trace ---
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.HandleReaderException(Exception e)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.<StoreReadAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.RowNestedResultEnumerator.<MoveNextAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.ObjectQueryNestedEnumerator.<TryReadToNextElementAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.ObjectQueryNestedEnumerator.<ReadElementAsync>d__f.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.ObjectQueryNestedEnumerator.<MoveNextAsync>d__a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Internal.LazyAsyncEnumerator`1.<FirstMoveNextAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.<SingleAsync>d__2d`1.MoveNext()
Inner exception:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.<StoreReadAsync>d__0.MoveNext()
Further technical details
EF version: 6.2.0
Database Provider: EntityFramework.SqlServer
Operating system: Windows 10
The text was updated successfully, but these errors were encountered:
I think the problem is a lot broader than this one case; It seems there quite a bit of library code which does not behave as we might expect. Having spent a few days wrangling similar issues cancelling operations being executed via a reasonably complex DAL, which includes the same kind of issue with operations on SqlClient (which frustratingly has no relationship to the provided CancellationToken), I'm also finding EF is wrapping the OperationCancelledException in an UpdateException, which is being, in turn, wrapped in a DbUpdateException.
I expect to be able to handle task cancellation using EF APIs in a similar fashion to this:
try { /* some async work * }
catch { OperationCanceledException ex) when (ex.CancellationToken == ct) { /* handle or throw depending on other exception handlers*/ }
Which clearly is more complicated if I must also handle wrapped exceptions too.
This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.
If you pass a method a cancellation token, you expect to catch OperationCanceledException (the base class of TaskCanceledException), not EntityCommandExecutionException with an InnerException of OperationCanceledException.
It's undesirable to have to catch both EntityCommandExecutionException and OperationCanceledException at all levels of the application because you don't know which it will be. It's an implementation detail leaking out.
Inner exception:
Further technical details
EF version: 6.2.0
Database Provider: EntityFramework.SqlServer
Operating system: Windows 10
The text was updated successfully, but these errors were encountered: