locked
Adding AspNet Identity to Existing Project that already has the database tables RRS feed

  • Question

  • User-2006371901 posted

    I see blogs and articles around the 'net on integrating aspnet Identity or OWIN to an existing MVC 5 project, but they are very vague or they show how to also implement the MIgration integration that builds the AspNetRoles and AspNetUsers* tables. I already hav those tables in my database from an earlier project, i just need to find out how to properly integrate the nuget packages and then the other  dbcontext configurations involved to allow password protection to existing project.

    Thanks in advance

    Ned

    Tuesday, October 8, 2019 6:25 PM

All replies

  • User475983607 posted

    Your question is not clear.   Are you trying to connect to an existing database that has Identity tables?

    Tuesday, October 8, 2019 6:57 PM
  • User-2006371901 posted

    I'm trying to add all the ASpnet Identity components to an existing MVC5 project in visual studio 2017. I already have the database tables for aspnet identity inside my database.

    Tuesday, October 8, 2019 7:20 PM
  • User-17257777 posted

    Hi Norkle,

    First you should install the Identity packages with NuGet.

    Make your user class inherit IdentityUser, make role class inherit IdentityRole, modify columns’ names to keep consist with the Identity original tables. Also you can add some columns as an extension

    Change your DbContext parent from DbContext to IdentityDbContext

    Extend UserManager if you have your own configuration and customization

    Configure OWIN in your project

    Set OWIN  in web.config

    This is my summary. For more details, you can refer to:

    https://stackoverflow.com/questions/31960433/adding-asp-net-mvc5-identity-authentication-to-an-existing-project/31963828

    Best Regards,

    Jiadong Meng.

    Wednesday, October 9, 2019 10:31 AM