How do I setup ASP.NET Identity 2.0 to use my own connection string

By default ASP.NET Identity 2.0 creates the 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 mentioned in the web.config as shown below,


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


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


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. Other option is to create connection string programmatically and pass it to the context class.

This is the way you can change the connection string of ASP.NET Identity 2.0.

Published by

Dhananjay Kumar

Dhananjay Kumar is Developer Evangelist for Infragistics. He is a 8 times Microsoft MVP and well respected Developer Advocate in India.He is the author of 900+ Blog Posts, and can often be found speaking around India at conferences and hosting free workshops for programmers across the country. So far, he has hosted 60 free workshops on various topics like JavaScript, Angular, WCF, ASP.NET MVC, C#, Azure etc. Follow him on twitter @debug_mode for all the updates about his blog posts and workshops. You can send him email at debugmode [at] outlook [dot] com

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s