Skip to content

Batch Operations (Update/Delete) fails with "Specified argument was out of the range of valid values" and are very slow #833

@stomasovic

Description

@stomasovic

Migrating EntityFramework.Extended library to a modern implementation and successor Z.EntityFramework.Plus.EF6 library, should be quite simple task. Changing few using directives, and changing some return parameters of methods for Future Queries, minor tweaks and all should be fine, right? Estimation was to upgrade it in a day, maybe two.

Well, it was not that easy. I was mostly afraid of complex Future queries we have, and that was mostly fine. But when moved to migrate Batch Operations, which should be simplest part of the migration, it failed. Details of the errors:

Message:
Specified argument was out of the range of valid values.
Parameter name: index

Stack Trace:
System.ArgumentOutOfRangeException
Enumerable.ElementAt[TSource](IEnumerable`1 source, Int32 index)
...
DbContextExtensions.GetModel(DbContext this)
BatchDelete.Execute[T](IQueryable`1 query)

The same error is for Update. Those three dots (...) are some obfuscated calls, and can not write meaningful stack trace.

Along with errors, it is also very slow to execute my tests. Tests using EntityFramework.Extended are running half a minute, but tests using Z.EnittyFramework.Plus.EF6 were running 3 to 6 minutes, which is more then 10 times slower and I feel the slowness.

EntityFramework.Extended worked fine for those Batch Operations, but new library failed. I tried on several DbContext within app, and it is the same issue on most of the DbContexts (one small context is working). I tried different versions of library, 9.x, 8.x, 7.x, even 1.x, same error always.

App is using DbInterceptors and Wrap DbSet calls, but even if remove wrapping DbContext.Set and interceptors, same error happened.
Any guideline how to debug and fix the issue.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions