Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An item with the same key has already been added. #108

Open
jkavimandan opened this issue Mar 13, 2017 · 4 comments
Open

An item with the same key has already been added. #108

jkavimandan opened this issue Mar 13, 2017 · 4 comments

Comments

@jkavimandan
Copy link

Job Message: Main Message: An item with the same key has already been added.
Main Message Stack Trace: at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at EntityFramework.Utilities.EfMappingFactory.GetMappingsForContext(DbContext context) at EntityFramework.Utilities.EFBatchOperation2
.InsertAll[TEntity](IEnumerable1 items, DbConnection connection, Nullable1 batchSize)

This error occurs intermittently, though no duplicate key is being passed to the InsertAll().

@digital-synapse
Copy link

+1
An item with the same key has already been added. at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
at EntityFramework.Utilities.EFBatchOperation2.InsertAll[TEntity](IEnumerable1 items, DbConnection connection, Nullable1 batchSize)

Does anyone have any idea what might be causing this?

@jkavimandan
Copy link
Author

I actually stopped usinf this utility. If you loop and add is still good. Didnt see any performance issues. Just do your own.

@sebastian-ilari
Copy link

+1 getting the followin stack trace when apparently trying to insert an empty collection:

System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary``2.Insert(TKey key, TValue value, Boolean add) at EntityFramework.Utilities.EfMappingFactory.GetMappingsForContext(DbContext context) in D:\Projects\GSAP-X-API\src\Externals\EntityFramework.Utilities\MappingHelper.cs:line 312 at EntityFramework.Utilities.EFBatchOperation``2.InsertAll[TEntity](IEnumerable``1 items, DbConnection connection, Nullable``1 batchSize) in D:\Projects\GSAP-X-API\src\Externals\EntityFramework.Utilities\EFBatchOperation.cs:line 115

I couldn't reproduce the issue using integration tests. My current versions are:

EntityFramework = 6.1.3
EntityFramework.Utilities = 1.0.2.0

@RudeySH
Copy link

RudeySH commented Feb 8, 2018

See #57. This is a concurrency issue that would have been fixed if #61 or #113 ever got merged. Unfortunately, this project hasn't been updated in a while. Check out my fork, it contains all the latest fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants