dotnet/efcore · error · NotSupportedException
EnumerableResetNotSupported
EnumerableResetNotSupported
Error message
This enumerator cannot be reset.
What it means
Thrown from Enumerator.Reset() on SplitQueryingEnumerable (SplitQueryingEnumerable.cs:304), the enumerator behind an AsSplitQuery(). Reset is unsupported because the enumerator drives a forward-only parent reader plus coordinated child readers that cannot be rewound. Code 'EnumerableResetNotSupported' is attached to this specific site.
Source
Thrown at src/EFCore.Relational/Query/Internal/SplitQueryingEnumerable.cs:304
if (_resultCoordinator != null)
{
foreach (var dataReader in _resultCoordinator.DataReaders)
{
dataReader?.DataReader.Dispose();
}
_resultCoordinator.DataReaders.Clear();
_resultCoordinator = null;
}
_dataReader = null;
_dbDataReader = null;
}
}
public void Reset()
=> throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);
}
private sealed class AsyncEnumerator : IAsyncEnumerator<T>
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandResolver _relationalCommandResolver;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly Func<QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator, T> _shaper;
private readonly Func<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator, Task>? _relatedDataLoaders;
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
private readonly bool _standAloneStateManager;
private readonly bool _detailedErrorEnabled;
private readonly IConcurrencyDetector? _concurrencyDetector;
private readonly IExceptionDetector _exceptionDetector;
private readonly CancellationToken _cancellationToken;
private IRelationalCommand? _relationalCommand;View on GitHub (pinned to dbf9771522)
Solutions
- Buffer with ToList()/ToListAsync() and iterate the in-memory list.
- Re-execute the IQueryable to obtain a fresh enumerator.
- Avoid Reset; use foreach over the materialized results.
- Feed reset-assuming components the buffered list, not the live split enumerable.
Example fix
// before
using var e = ctx.Orders.AsSplitQuery().Include(o => o.Items).GetEnumerator();
e.MoveNext();
e.Reset(); // throws EnumerableResetNotSupported
// after
var orders = ctx.Orders.AsSplitQuery().Include(o => o.Items).ToList();
foreach (var o in orders) { /* safe */ } Defensive patterns
Strategy: validation
Validate before calling
var orders = ctx.Orders.AsSplitQuery().Include(o => o.Items).ToList(); // buffer for reuse
Type guard
static bool IsResettable<T>(IEnumerable<T> s) => s is IList<T> or Array;
Try / catch
try { e.Reset(); }
catch (NotSupportedException) { var buffered = query.ToList(); } Prevention
- Materialize split-query results before re-iterating.
- Avoid Reset() on EF enumerators; use foreach over a buffered list.
- Pass buffered lists to reset-assuming components.
When it happens
Trigger: Calling IEnumerator.Reset() on an enumerator from an AsSplitQuery() query. Triggered by code or libraries that re-iterate via Reset, or by manually holding and reusing an enumerator from a split query.
Common situations: Custom helpers applied to split-query enumerables; ported LINQ-to-Objects code; libraries that buffer via Reset.
Related errors
- This enumerator cannot be reset.
- This enumerator cannot be reset.
- This enumerator cannot be reset.
- This enumerator cannot be reset.
- This enumerator cannot be reset.
AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06).
Data as JSON: /api/errors/b2ada8ff3d59fb25.
Report an issue: GitHub.