DB2 - Problem description
Problem IT38810 | Status: Closed |
SYSTEM.ARGUMENTEXCEPTION OCCURS WHILE PERFORMING DML OPERATION ON LARGE BATCH STATEMENTS VIA EF CORE | |
product: | |
DB2 CONNECT / DB2CONNCT / B50 - DB2 | |
Problem description: | |
When Application performs DML operation on a Large batch of statements using IBM Entity Framework Core driver, following error can occur: System.ArgumentException: An item with the same key has already been added. Key: p98 at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBa tch.CreateStoreCommand() at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBa tch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at IBM.EntityFrameworkCore.Update.Internal.Db2BatchExecutor.Execute Async(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at IBM.EntityFrameworkCore.Update.Internal.Db2BatchExecutor.Execute Async(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at IBM.EntityFrameworkCore.Update.Internal.Db2BatchExecutor.Execute Async(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManag er.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManag er.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) System.ArgumentException: An item with the same key has already been added. Key: p98 at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBa tch.CreateStoreCommand() at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBa tch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at IBM.EntityFrameworkCore.Update.Internal.Db2BatchExecutor.Execute Async(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at IBM.EntityFrameworkCore.Update.Internal.Db2BatchExecutor.Execute Async(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at IBM.EntityFrameworkCore.Update.Internal.Db2BatchExecutor.Execute Async(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManag er.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManag er.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * DB2 Connect .NET EF Core 5.0 users * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to IBM Entity Framework Core Provider version * * 5.0.0.500 NuGet package * * NuGet packages are located: * * https://www.nuget.org/packages/IBM.EntityFrameworkCore/5.0.0 * * .500 * * https://www.nuget.org/packages/IBM.EntityFrameworkCore-lnx/5 * * .0.0.500 * * https://www.nuget.org/packages/IBM.EntityFrameworkCore-osx/5 * * .0.0.500 * **************************************************************** | |
Local Fix: | |
Configure MaxBatchSize to 42. For example : options.UseDb2(, p => { p.SetServerInfo(, ); p.MaxBatchSize(42); })) | |
Solution | |
Workaround | |
**************************************************************** * USERS AFFECTED: * * DB2 Connect .NET EF Core 5.0 users * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to IBM Entity Framework Core Provider version * * 5.0.0.500 NuGet package * * NuGet packages are located: * * https://www.nuget.org/packages/IBM.EntityFrameworkCore/5.0.0 * * .500 * * https://www.nuget.org/packages/IBM.EntityFrameworkCore-lnx/5 * * .0.0.500 * * https://www.nuget.org/packages/IBM.EntityFrameworkCore-osx/5 * * .0.0.500 * **************************************************************** | |
Comment | |
Problem fixed in IBM Entity Framework Core Provider and will be available on NuGet via version 5.0.0.500. | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 26.10.2021 10.01.2022 24.10.2022 |
Problem solved at the following versions (IBM BugInfos) | |
Problem solved according to the fixlist(s) of the following version(s) |