How To Set Up ASP.Net Identity 2.0 to Use Custom Connection String

By default ASP.NET Identity 2.0 creates a database inside the App_Data directory of the application. ASP.NET Identity 2.0 works on the Entity Framework Code First approach and it reads the connection string specified in the web.config as shown below:

web config

In the ApplicationDbContext class you can find that connection string named DefaultConnection has been used. You can find the ApplicationDbContext class inside the IdentityModels.cs file.

DefaultConnection

You may have a requirement to use some other database server and the database to configure the ASP.NET Identity 2.0. The simplest way you can do this is by changing the connection string the web.config file.

default connection

DJPC is database server name of my development machine. ASP.NET Identity 2.0 works on the EF Code First approach, it will create the database DelhiDevDayExample, if it's not already there. Another option is to create the connection string programmatically and pass it to the context class.

This is how to change the connection string of ASP.NET Identity 2.0.

Up Next
    Ebook Download
    View all
    Learn
    View all