Xeddon
Xeddon

Reputation: 449

ASP.NET Identity with custom "user" table

I want to use OWIN. But I need more columns in the user table. I also want to use NHibernate.

What is the way to do this? Extending the user table from OWIN. I don't know if that is possible. Second, I don't know whether I can get caching problems, or not.

Or, I make a second user table for my own user data with a "UserID" property as foreign key referencing to the user table for OWIN?

Upvotes: 0

Views: 6182

Answers (1)

Masoud Andalibi
Masoud Andalibi

Reputation: 3228

I'd say use the Asp.NET Identity anyways. if you want to have more properties for your ApplicationUser you can add them like below:

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; }
    //...
}

You can even create methods for User.Identity to get the values of the properties as easily as GetUserId() method. Take a Look at this.

Upvotes: 1

Related Questions