I am using Asp.Net Identity 2.2.1. The way I did this was created by my own user:
public class MyUser : IUser {...}
Then create your own UserStore: (Implement all the methods necessary for the implemented interfaces, and use these methods to pull / paste the data using your data access. For example, I created another dal class on which I use dapper to access the database , I presented an example of one method in my user repository, but this is the same idea for all the other methods that 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); }
Then the method on my dal.cs looks something like this:
public MyUser FindByUsername(string username) {
Then on my UserManager I installed the user repository as follows:
public UserManager() : base(new MyUserStore()) {
Note : Not all methods in MyUserStore must access the database because many of them call the FindUser ... methods or the UpdateUser method. For example:
public Task<int> IncrementAccessFailedCountAsync(MyUser user) {
source share