Search code examples
c#asp.net-core-mvcasp.net-identity-2

using aspnet identity with custom tables


I am working on asp.net MVC core application. I have custom database with users and roles tables. I want to use asp.net identity with custom tables so that I don't have to use aspnetusers, aspnet roles tables. How to do it with asp.net identity and asp.net core


Solution

  • Good luck with that! :) I have just gone through that process last few days. I've got it to work but its really painful at some stages.

    In short:

    1. You need to create your own user model that implements IUser interface.
    2. You need to create your own DAL that gets data from your custom db tables
    3. You need to implement your own UserStore that implements different interfaces based on what functionality of asp.identity you want to use

    This link will help you: https://www.asp.net/identity/overview/extensibility/overview-of-custom-storage-providers-for-aspnet-identity