dotnet/efcore · error · NotSupportedException

This enumerator cannot be reset.

Error message

This enumerator cannot be reset.

What it means

Thrown when calling Reset() on the IEnumerator<T> from a SplitQueryingEnumerable. Split query enumerators coordinate multiple DbDataReaders across separate round-trips and cannot be rewound; Reset() throws NotSupportedException per IEnumerator conventions.

Solutions

  1. Do not call Reset(); re-execute the split query for fresh results.
  2. Call ToList()/ToListAsync() to materialize before passing to code that may reset.
  3. Switch to AsSingleQuery() if reset support is somehow required (though still unsupported).
  4. Report the issue to the library/framework invoking Reset().

Example fix

// before
using var e = context.Blogs
    .AsSplitQuery()
    .Include(b => b.Posts)
    .GetEnumerator();
e.Reset(); // throws

// after
var blogs = context.Blogs
    .AsSplitQuery()
    .Include(b => b.Posts)
    .ToList();
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Calling .Reset() on the enumerator of a query using AsSplitQuery() or UseSplitQuery(). The enumerator manages a SplitQueryResultCoordinator with multiple data readers, making a rewind architecturally impossible.

Common situations: Third-party library, test harness, or data-binding infrastructure that generically calls Reset() on any IEnumerator. Attempting to replay split query results without re-executing.

Related errors


AI-assisted analysis of dotnet/efcore@3a2006ef56 (2026-08-11). Data as JSON: /api/errors/e12363c95b4d8637. Report an issue: GitHub.

Appendix: 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 3a2006ef56)