Open Closed

bulk user creation #5935


User avatar
0
shobhit created
  • ABP Framework version: v4.2.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..) SQL Server
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

How i can create Bulk user and user record should be commited in DB without waiting for transaction to complete.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You can create users using a separate transaction. for example:

    foreach(var item in list)
    {
        using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional:true))
        {
            try
            {
                var user = new IdentityUser(
                    GuidGenerator.Create(),
                    <username>, /// item.Username
                    <email>, // item.email
                    CurrentTenant.Id
                );
        
                user.SetPhoneNumber(<phoneNumber>, false);
                
                await UserManager.CreateAsync(user, <password>)).CheckErrors();
        
                await uow.CompleteAsync();
            }
            catch (Exception e)
            {
                await uow.RollbackAsync();
                throw e;
            }
        }
    }
    
    
    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.