Base solution for your next web application
Open Closed

Issue with Unit of Work after upgrading to latest version #2444


User avatar
0
arifhshigri created

Hi,

I have updated the version of ABP (and its dependencies) from 1.0.0.0-* to 1.3.1, and since then i am facing error when i try to create user Here is my Code

[AbpAuthorize(PermissionNames.UsersCreate)]
        [UnitOfWork]
        public async Task<UserListDto> CreateUser(CreateUserInput input)
        {
            SwitchTenant(input.TenantId);
            var user = input.MapTo<User>();
            
            user.Password = new PasswordHasher().HashPassword(input.Password);
            user.IsEmailConfirmed = true;
            user.TenantId = CurrentUnitOfWork.GetTenantId();

            CheckErrors(await UserManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync();
            await UserManager.AddToRolesAsync(user.Id, input.UserRoles.ToArray());
            return user.MapTo<UserListDto>();
        }

on UserManager.AddToRolesAsync Line it throws the following Exception "User id=x already exist " In the database when i check there is no user with id=x , and the current identity table is incremented.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please upgrade to Abp v1.4.1 and Abp.Zero to v1.4.0. This problem should be fixed. See this issue for details <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/issues/293">https://github.com/aspnetboilerplate/mo ... issues/293</a>.