- ABP Framework version: v2.9.0
- UI type: Angular
- Identity Server Seperated (Angular): yes
- Exception message and stack trace: AbpIdentityResultException, AbpDbConcurrencyException, DbUpdateConcurrencyException
- Steps to reproduce the issue:
Hello,
I am trying to customize IdentityUserManager without success.
I wanted to update my custom User Entity properties after User created.
But that code gives DbConcurrency Errors.
I wanted to handle(EfCore https://docs.microsoft.com/en-us/ef/core/saving/concurrency) the exception but could not catch any exception.
Any advice is helpful, thanks.
13 Answer(s)
- 
    0Hi, ABP uses the unit of work system to save changes after the method returns, but you can save changes manually: Try : try { //...... await _myRepository.UpdateAsync(myEntity); await CurrentUnitOfWork.SaveChangesAsync(); } catch(DbUpdateConcurrencyException ex) { // handle exception }See Unit of Work Document learn more about unit of work system. 
- 
    0Nope optimistic concurrency failure again. I tried many usage combination of UOW. Transactional UOW etc. Maybe i need an example project. 
- 
    0Can you provide steps to reproduce? I will try reproduce your problem locally , Thanks. 
- 
    0Hi @liangshiwei, I sent you a mail. I did a small demo application. Did you get the email? Thanks. 
- 
    0OK, I will check it. Have a ncie day. 
- 
    0Hi, I create an example for you https://github.com/realLiangshiwei/AbpQa274. You can see that after create the user, change the user object again. You have three options: - Overwrite IdentityUserAppService, update the user at the end of the method.
- Use entity extend system.(this way is used in the example).
- Can be simpler,Use object extend system to extend Dto and pass the DisplayNameparameter in the create user request. see https://github.com/abpframework/abp/issues/4467.
 
- Overwrite 
- 
    0Hi, First of all i thank you, but Option 2 saves property as ExtraProperty which is not we want because our property is a real DB field. I assume Option 3 is the same. I will try Option 1, i will write the result. 
- 
    0Hi, It is a separate field in database table: https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities#entity-extensions-ef-core You can run the sample project and add users. You will see it is a separate field in the database. 
- 
    0I had to use builder.Ignore<MyUser>();This code when dbmigration model creating but in your demo application you didn't use this option. If i don't use this, it shows "I can't map ExtraProperties" error when trying to add a new migration. 
- 
    0Is this AppUser name necessary ? Because we removed it and we added a new entity like MyUser. 
- 
    0I fixed this but i used this code in MigrationDbContext.OnModelCreating builder.Ignore<MyUser>();Fyi. 
- 
    0AppUseris no different from yourMyUser, you can start directly fromAppUser.We changed the startup template and removed the ConfigureCustomUserPropertiesmethod in later versions. You can change your code according to the latest template.Because you fixed this. so I close this question. if you still have this problem, please reopen. 
- 
    0No problem but only strange thing is this code. Because you didn't use this, but i had to use this. I got an existing db, maybe the problem cause of this. builder.Ignore<MyUser>();



 
                                