efcore: Object reference not set to an instance of an object. at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.d__12.MoveNext()
I’m awaiting a handful of EF Core Queries and I’m seeing this exception
Exception message:Object reference not set to an instance of an object
Stack trace:
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.<BufferAllAsync>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 Microsoft.EntityFrameworkCore.Query.RelationalQueryContext.<RegisterValueBufferCursorAsync>d__14.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 Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.<BufferlessMoveNext>d__9.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 Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.<ExecuteAsync>d__6`2.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 Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.<MoveNext>d__8.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 Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.SelectAsyncEnumerable`2.SelectAsyncEnumerator.<MoveNext>d__4.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 Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.<_SingleOrDefault>d__123`1.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 Microsoft.EntityFrameworkCore.Query.Internal.TaskResultAsyncEnumerable`1.Enumerator.<MoveNext>d__3.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 Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.SelectAsyncEnumerable`2.SelectAsyncEnumerator.<MoveNext>d__4.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 Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.<MoveNext>d__5.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.Runtime.CompilerServices.TaskAwaiter.GetResult()
at DealBank.Data.DealBankRepository.<SaveDealAsync>d__4.MoveNext() in C:\Users\mdepouw\Source\Repos\MyProject\MyCode.cs:line 75
Steps to reproduce
Turn off MARS and await mutliple queries I think will reproduce it.
MultipleActiveResultSets=false;
var task1 = GetDataAsync();
var task2 = GetData2Async();
await Task.WhenAll(task1, task2);
Further technical details
EF Core version: (found in project.json or packages.config) neither of these files exist for me…
Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Win10 IDE: VS 2017
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (8 by maintainers)
Commits related to this issue
- Fixes for #8305, #8026 and possibly flaky Test: AsyncQueryTestBase.Mixed_sync_async_query (part of #7160) - Moved query async Semaphore to RelationalConnection so multiple top-level queries can be se... — committed to dotnet/efcore by anpete 7 years ago
- Fixes for #8026 and possibly flaky Test: AsyncQueryTestBase.Mixed_sync_async_query (part of #7160) - Moved query async Semaphore to RelationalConnection so multiple top-level queries can be serialize... — committed to dotnet/efcore by anpete 7 years ago
- Fixes for #8026 and possibly flaky test: AsyncQueryTestBase.Mixed_sync_async_query (part of #7160) - Moved query async Semaphore to RelationalConnection so multiple top-level queries can be serialize... — committed to dotnet/efcore by anpete 7 years ago
- Fixes for #8026 and possibly flaky test: AsyncQueryTestBase.Mixed_sync_async_query (part of #7160) - Moved query async Semaphore to RelationalConnection so multiple top-level queries can be serialize... — committed to dotnet/efcore by anpete 7 years ago
- Fixes for #8026 and possibly flaky test: AsyncQueryTestBase.Mixed_sync_async_query (part of #7160) - Moved query async Semaphore to RelationalConnection so multiple top-level queries can be serialize... — committed to dotnet/efcore by anpete 7 years ago
- Fixes for #8026 and possibly flaky test: AsyncQueryTestBase.Mixed_sync_async_query (part of #7160) - Moved query async Semaphore to RelationalConnection so multiple top-level queries can be serialize... — committed to dotnet/efcore by anpete 7 years ago
- Fixes for #8026 and possibly flaky test: AsyncQueryTestBase.Mixed_sync_async_query (part of #7160) - Moved query async Semaphore to RelationalConnection so multiple top-level queries can be serialize... — committed to dotnet/efcore by anpete 7 years ago
@v1n1akabozo This should work in 2.0. I.e. You can spawn several tasks and await all of them via something like Task.WhenAll.