I am using Asp.Net Identity 2.2.1.
The way I implemented this was by creating my own User:
public class MyUser : IUser {...}
Then create my own UserStore:
(Implement all the methods required by the interfaces you implemented, and on those methods pull/insert the data using your data access. For example I created another dal class on which I use dapper to access the database, I provided the example of one method in my user store, but it is the same idea for all other methods you implement)
public class MyUserStore : IUserStore<MyUser>, IUserPasswordStore<MyUser>, IUserLockoutStore<MyUser, string>, IUserEmailStore<MyUser>
{
public Task<MyUser> FindByNameAsync(string userName)
{
MyUser muser = dal.FindByUsername(userName);
if (muser != null)
return Task.FromResult<User>(muser);
return Task.FromResult<MyUser>(null);
}
//... all other methods
}
Then the method on my dal.cs looks something like this:
public MyUser FindByUsername(string username)
{
//pull user from the database however you want to based on the username,
//in my case here is where I used Dapper to query the db and return the User object with the data on it, but you can do it however you want.
return myUser; //object with data on it
}
Then on my UserManager I set the user store like this:
public UserManager() : base(new MyUserStore())
{
//anything else you need on the constructor
}
NOTE:
Not all the methods on MyUserStore need to access the database, because a lot of them call the FindUser... methods or the UpdateUser method. So for example:
public Task<int> IncrementAccessFailedCountAsync(MyUser user)
{
//here I just updated the user object as I know that UpdateAsync() method will be called later.
return Task.FromResult<int>(++user.FailedAttempts);
}