MVC5 Login to user database

What if you have your own database and BAL (Business Access Layer) and don't want to use DefaultConnection

both the ASP.NET template database tables but my own user tables?

How can you use a custom database?

ConnectionString:

public class AppDbContext : IdentityDbContext<AppUser>
{
    public AppDbContext() : base("DefaultConnection")
    {
    }
}

      

Web.config

<add name="DefaultConnection" 
   connectionString="Data Source=(LocalDb)\v11.0;
                     AttachDbFilename=|DataDirectory|\NakedIdentity-Mvc.mdf;
                     Initial Catalog=NakedIdentity-Mvc;Integrated Security=True" 
   providerName="System.Data.SqlClient" />

      

+3


source to share


2 answers


You can customize your tables, storage and your classes.
The process is not easy, but with a little work you can do it. I answered a similar question a few days ago.
You can find here.

You can find a project on github where I tried to set up all the tables involved in the authentication / authorization process.



This is another answer where you can read something more about using a different store for your users and roles.

+5


source


You can always specify the database you want to talk to - this is actually the idea behind the connection string configuration. You need to change the attribute connectionString

to point to the correct database.



Here is a good source of information on connection strings

+1


source







All Articles