public async Task <LdapAuthenticationModeModel> UpdateAsync(LdapAuthenticationModeModel ldapAuthenticationMode) { // Record plain text password and clear from model string password = ldapAuthenticationMode.Password; ldapAuthenticationMode.Password = string.Empty; a3SContext.Entry(ldapAuthenticationMode).State = EntityState.Modified; // Replace Ldap Attribute Links a3SContext.RemoveRange(a3SContext.LdapAuthenticationModeLdapAttribute.Where(x => x.LdapAuthenticationModeId == ldapAuthenticationMode.Id)); await a3SContext.SaveChangesAsync(); // Now store encrypted password await StoreEncryptedPassword(ldapAuthenticationMode.Id, password); return(ldapAuthenticationMode); }