Open Closed

About identity user management or identity user service #2735


User avatar
0
ldacnfinit created
  • 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);
    ...
}
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please share full error info.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ldacnfinit created

    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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ldacnfinit created

    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!

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.