ASP.NET 自定义身份 "user" table

ASP.NET Identity with custom "user" table

我想使用 OWIN。但是我需要用户 table 中的更多列。我也想用NHibernate

有什么方法可以做到这一点? 从 OWIN 扩展用户 table。我不知道那是否可能。其次,我不知道我是否会遇到缓存问题。

或者,我为自己的用户数据创建第二个用户 table,并使用 "UserID" 属性 作为外键引用用户 table for [=13] =]?

我会说无论如何都要使用 Asp.NET 身份。如果你想为你的 ApplicationUser 添加更多属性,你可以像下面这样添加它们:

public class ApplicationUser : IdentityUser
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;
    }

    // Your Extended Properties
    public string FirstName{ get; set; }
    public string LastName{ get; set; }
    //...
}

您甚至可以为 User.Identity 创建方法来像 GetUserId() 方法一样轻松获取属性值。看看