IUserEmailStore 是保存到数据库还是实体?

Does IUserEmailStore save to the database or the entity?

我正在编写 UserStore(T) 的自定义实现,以便与较旧的数据库模式交互。我的 IUserEmailStore.SetEmailAsync 实现应该将此更改保存到数据库还是只在用户实体上设置电子邮件?也就是说,identity系统调用这个方法后是不是调用了UpdateAsync

UserManager 确实在设置电子邮件后调用 UpdateAsync

public virtual async Task<IdentityResult> SetEmailAsync(TKey userId, string email)
{
    ThrowIfDisposed();
    var store = GetEmailStore();
    var user = await FindByIdAsync(userId).WithCurrentCulture();
    if (user == null)
    {
        throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.UserIdNotFound,
                    userId));
    }
    await store.SetEmailAsync(user, email).WithCurrentCulture();
    await store.SetEmailConfirmedAsync(user, false).WithCurrentCulture();
    await UpdateSecurityStampInternal(user).WithCurrentCulture();
    return await UpdateAsync(user).WithCurrentCulture();
}

因此,您的商店唯一需要做的就是在用户对象上设置电子邮件(并且不保存)。