You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to BulkInsert a lot of rows in a table on a schedule.
Whenever hangfire first executes the function, everything runs smoothly. However second time I try to bulkinsert, i get this error:
System.IndexOutOfRangeException: 'There is no row at position 0.'
Code
publicvoidAddRange(List<CardVehiclesUsedPo>cvu){db.BulkInsert(cvu,
options =>{options.InsertIfNotExists=true;options.AllowDuplicateKeys=true;options.ColumnPrimaryKeyExpression= p =>new{p.DriverCardId,p.VehicleOdometerBegin,p.VehicleRegistrationNumber};});db.SaveChanges();}
If you are seeing an exception, include the full exceptions details (message and stack trace).
System.IndexOutOfRangeException: 'There is no row at position 0.'
Exception message:
Stack trace:
System.IndexOutOfRangeException
There is no row at position 0.
at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
at System.Data.DataRowCollection.get_Item(Int32 index)
at ?.?(? ?, DbCommand ?)
at ?.?(? ?, DbCommand ?)
at ?.Execute(List`1 actions)
at ?.?(List`1 ?)
at Z.BulkOperations.BulkOperation.Execute()
at Z.BulkOperations.BulkOperation.BulkInsert()
at ?.BulkInsert[T](DbContext this, IEntityType entityType, IEnumerable`1 list, Action`1 options, SavingSelector savingSelector, Boolean forceSpecificTypeMapping, Boolean isOptimized)
at ?.BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options, Boolean isBulkSaveChanges, Boolean isOptimized)
at DbContextExtensions.BulkInsert[T](DbContext this, IEnumerable`1 entities, Action`1 options)
at Redacted.Context.ContextHandlers.CardVehiclesUsedCh.AddRange(List`1 cvu) in C:\Users\StianHåve\Videos\REPOS\Redacted\Context\ContextHandlers\CardVehiclesUsedCh.cs:line 40
at Redacted.Services.DriverFileService.UploadCardVehiclesUsed(DriverFileInfo file) in C:\Users\StianHåve\Videos\REPOS\Redacted\Services\DriverFileService.cs:line 189
at Redacted.Services.DriverFileService.Test() in C:\Users\StianHåve\Videos\REPOS\Redacted\Services\DriverFileService.cs:line 66
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
I’m out of the office. But is it possible to share the code & database privately?
Upon further investigation I found that this problem only happened to certain json files and data, but there is no clear indication on what’s causing the error as the models are the same.
Description
I am trying to
BulkInsert
a lot of rows in a table on a schedule.Whenever hangfire first executes the function, everything runs smoothly. However second time I try to bulkinsert, i get this error:
Code
Data
The data i am trying to add:
Database
Exception
If you are seeing an exception, include the full exceptions details (message and stack trace).
Further technical details
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="8.102.0" />
The text was updated successfully, but these errors were encountered: