{"record":{"id":"b2ada8ff3d59fb25","repo":"dotnet/efcore","slug":"enumerableresetnotsupported","errorCode":"EnumerableResetNotSupported","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/SplitQueryingEnumerable.cs","lineNumber":304,"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<T>\n    {\n        private readonly RelationalQueryContext _relationalQueryContext;\n        private readonly RelationalCommandResolver _relationalCommandResolver;\n        private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;\n        private readonly Func<QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator, T> _shaper;\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 _detailedErrorEnabled;\n        private readonly IConcurrencyDetector? _concurrencyDetector;\n        private readonly IExceptionDetector _exceptionDetector;\n        private readonly CancellationToken _cancellationToken;\n\n        private IRelationalCommand? _relationalCommand;","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.Relational/Query/Internal/SplitQueryingEnumerable.cs#L286-L322","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom helpers applied to split-query enumerables; ported LINQ-to-Objects code; libraries that buffer via Reset.","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."],"exampleFix":"// before\nusing var e = ctx.Orders.AsSplitQuery().Include(o => o.Items).GetEnumerator();\ne.MoveNext();\ne.Reset(); // throws EnumerableResetNotSupported\n\n// after\nvar orders = ctx.Orders.AsSplitQuery().Include(o => o.Items).ToList();\nforeach (var o in orders) { /* safe */ }","handlingStrategy":"validation","validationCode":"var orders = ctx.Orders.AsSplitQuery().Include(o => o.Items).ToList(); // buffer for reuse","typeGuard":"static bool IsResettable<T>(IEnumerable<T> s) => s is IList<T> or Array;","tryCatchPattern":"try { e.Reset(); }\ncatch (NotSupportedException) { var buffered = query.ToList(); }","preventionTips":["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."],"tags":["ef-core","enumerator","reset","split-query","datareader"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}