Jake Dawson
Jake Dawson

Reputation: 89

How can I use an int instead of a Guid for the id column in IdentityUser class?

Using web api 2 and have authentication set up and what not. But I'm really not a fan of the Guid for user id. I will prefer an auto increment int id. Is it possible to change it implementing my own IdentityUser? How will I start?

Upvotes: 0

Views: 280

Answers (1)

MichaC
MichaC

Reputation: 13380

If you want int ids, you need to create your own implementation of IUser and IUserStore for your custom IUser class

public interface IUser
{
    string Id { get; }
    string UserName { get; set; }
}

public interface IUserStore<TUser> : IDisposable where TUser : IUser
{
    Task CreateAsync(TUser user);
    Task DeleteAsync(TUser user);
    Task<TUser> FindByIdAsync(string userId);
    Task<TUser> FindByNameAsync(string userName);
    Task UpdateAsync(TUser user);
}

Upvotes: 1

Related Questions