Abp: Unit Of Work - Collection was modified enumeration operation may not execute

Created on 1 Jul 2019  路  12Comments  路  Source: abpframework/abp

Hi,
I have a problem while handling CRUD event of an entity whenever I try to read objects on the different DbContext it gives me this error:

Capture1

After look up the code in Uow I found this :
Capture

Should _databaseApis.Values be _databaseApis.Values.ToImmutableList().

Many thanks for your help .

enhancement

All 12 comments

ToImmutableList doesn't seem to solve the underlying problem. Can you share some code to reproduce this problem?

Sure. I have custom the AbpAuditPropertySetter to use int instead of GUID so i override the SetCreationAuditProperties to use my CustomAuditPropertySetter.
Capture3

The CurrentUser.Id is get by query the database by another DbContext

Capture4
Capture5
Capture6

@hieutns96 Can you share the complete project code? You can create a project using cli. : )

@maliming i affraid i cannot share the complete project but I found this issue on the old project ASP Boiplerplate that have same issue with me. https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1860

I belive the _databaseApis.Values has been change during the transaction of SaveChangeAsync :)

Thank you very much, we will confirm this.

@maliming Thank you very much, I really appreciate your help. If it is possible when you find the issue, please share with me work around for this to work :)

I have the same issue, looking ahead to meet the fix it right now.

when do you deployment new version 0.19.0? it's an urgent issue with my project.

hi @hieutns96
You can temporarily create the MyUnitOfWork class with the latest code and then replace the built-in UnitOfWork.

@maliming How to replace the built-in UnitOfWork. I'm using the volo.abp.core from Nuget, and have the abp source code from the GitHub.

Use dependency injection to replace built-in components.

ReplaceServices: Set true to replace services if they are already registered before. Uses Replace extension method of IServiceCollection.

https://docs.abp.io/en/abp/latest/Dependency-Injection#dependency-attribute

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wocar picture wocar  路  3Comments

hikalkan picture hikalkan  路  3Comments

wocar picture wocar  路  3Comments

zsanhong picture zsanhong  路  3Comments

hikalkan picture hikalkan  路  3Comments