ABP Framework version: v4.4.3
UI type: Angular
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes
Exception message and stack trace: If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.Object name: 'IdentityDbContext'.
Steps to reproduce the issue:"
[UnitOfWork]
public virtual async Task<ListResultDto<AppUserDto>> ImportByExcelFile(IFormFile file)
{
...
await _identityUserManager.CreateAsync(ObjectMapper.Map<CreateUpdateAppUserDto, IdentityUser>(s), userPwd, false);
...
}
4 Answer(s)
-
0
hi
Please share full error info.
-
0
hi
Please share full error info.
Because the number of log words exceeded the maximum allowed for a post, I posted a blog with a link to https://www.cnblogs.com/zinan/p/16007487.html
-
0
Hi @ldacnfinit, can you try to create a UOW in your
ImportByExcelFile
method manually, like below:private readonly IUnitOfWorkManager _unitOfWorkManager; public virtual async Task> ImportByExcelFile(IFormFile file) { using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) { //... await _identityUserManager.CreateAsync(ObjectMapper.Map(s), userPwd, false); await uow.CompleteAsync(); } }
https://docs.abp.io/en/abp/latest/Unit-Of-Work#begin-a-new-unit-of-work
-
0
Hi @ldacnfinit, can you try to create a UOW in your
ImportByExcelFile
method manually, like below:private readonly IUnitOfWorkManager _unitOfWorkManager; public virtual async Task> ImportByExcelFile(IFormFile file) { using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) { //... await _identityUserManager.CreateAsync(ObjectMapper.Map(s), userPwd, false); await uow.CompleteAsync(); } }
https://docs.abp.io/en/abp/latest/Unit-Of-Work#begin-a-new-unit-of-work
Ok, Thanks a lot! It works!