It may not be that difficult to remove ApplicationDbContext from your ui project. The most complete way is to create a webapi project that will expose the IUserStore functions, or at least only the functions you need, and you wonβt need all of them. The web api methods simply delegate the underlying entity used in the DAL or not. How (with repository)
[HttpGet] [Route("finduserbyid/{userId}")] public async Task<IHttpActionResult> FindByIdAsync(string userId) { var verifiedUser = await this.UnitOfWork.ApplicationUserRepository.FindByIdAsync(userId); if (verifiedUser == null) { return NotFound(); } return Ok(verifiedUser); }
Then create a new class in your ui project or utility project that implements IUserStore and calls webapi for the data. I was able to do this in a day or so, not very difficult. Like this:
public class RemoteUserStore<T> : IUserStore<ApplicationUser> , IUserPasswordStore<ApplicationUser> , IUserLoginStore<ApplicationUser> , IUserRoleStore<ApplicationUser> , IUserEmailStore<ApplicationUser> { public RemoteUserStore(string identityServerUrl) { _appServerUrl = identityServerUrl; } private readonly string _appServerUrl; private string IdentityServerUrl { get { return _appServerUrl; } } public async Task CreateAsync(ApplicationUser user) { var client = new HttpClient(); string url = string.Format("{0}/api/identity/createuser/{1}", IdentityServerUrl, user.Id); var userContent = MapApplicationUserToFormContent(user); var result = await client.PostAsync(url, userContent); }
However, you cannot remove the reference to the entity infrastructure, since the user interface actually uses ApplicationUser with IdentityUser as the base class and is defined in microsoft.aspnet.identity.entityframework
source share