{"record":{"id":"0925bec5ff067988","repo":"dotnet/efcore","slug":"this-enumerator-cannot-be-reset-0925be","errorCode":null,"errorMessage":"This enumerator cannot be reset.","messagePattern":"This enumerator cannot be reset\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Query/Internal/GroupBySplitQueryingEnumerable.cs","lineNumber":383,"sourceCode":"                if (_resultCoordinator != null)\n                {\n                    foreach (var dataReader in _resultCoordinator.DataReaders)\n                    {\n                        dataReader?.DataReader.Dispose();\n                    }\n\n                    _resultCoordinator.DataReaders.Clear();\n\n                    _resultCoordinator = null;\n                }\n\n                _dataReader = null;\n                _dbDataReader = null;\n            }\n        }\n\n        public void Reset()\n            => throw new NotSupportedException(CoreStrings.EnumerableResetNotSupported);\n    }\n\n    private sealed class AsyncEnumerator : IAsyncEnumerator<IGrouping<TKey, TElement>>\n    {\n        private readonly RelationalQueryContext _relationalQueryContext;\n        private readonly RelationalCommandResolver _relationalCommandResolver;\n        private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;\n        private readonly Func<QueryContext, DbDataReader, TKey> _keySelector;\n        private readonly Func<QueryContext, DbDataReader, object[]> _keyIdentifier;\n        private readonly IReadOnlyList<Func<object, object, bool>> _keyIdentifierValueComparers;\n        private readonly Func<QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator, TElement> _elementSelector;\n        private readonly Func<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator, Task>? _relatedDataLoaders;\n        private readonly Type _contextType;\n        private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;\n        private readonly bool _standAloneStateManager;\n        private readonly bool _detailedErrorsEnabled;\n        private readonly IConcurrencyDetector? _concurrencyDetector;\n        private readonly IExceptionDetector _exceptionDetector;","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Query/Internal/GroupBySplitQueryingEnumerable.cs#L365-L401","documentation":"Thrown when calling Reset() on the IEnumerator returned by a GroupBy query using split-query mode (AsSplitQuery()). Split query enumerators manage multiple DbDataReaders and a result coordinator; they are inherently forward-only and cannot be rewound. Reset() throws NotSupportedException per IEnumerator conventions.","triggerScenarios":"Calling .Reset() on the enumerator of a GroupBy query executed with UseSplitQuery() or AsSplitQuery(). The enumerator manages multiple data readers for separate round-trips, making rewind impossible.","commonSituations":"Library or test framework code that generically calls Reset() on any IEnumerator. Attempting to re-enumerate split-query results without re-running the query.","solutions":["Do not call Reset(); re-execute the GroupBy split query for fresh results.","Call ToList()/ToListAsync() to materialize before passing results to code that may reset.","Report the Reset() usage to the library/framework that triggers it."],"exampleFix":"// before\nusing var e = context.Orders\n    .AsSplitQuery()\n    .GroupBy(o => o.CustomerId)\n    .GetEnumerator();\ne.Reset(); // throws\n\n// after\nvar groups = context.Orders\n    .AsSplitQuery()\n    .GroupBy(o => o.CustomerId)\n    .ToList();","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call Reset() on split-query enumerators — they manage multiple readers and cannot rewind.","Materialize split-query GroupBy results with ToList()/ToListAsync() first.","Prefer single-query mode (AsSingleQuery) if reset-like replay is somehow needed — though still unsupported."],"tags":["enumerator","reset","groupby","split-query","forward-only"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}