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

Actually all you have to do is change the DefaultConnection connectionString to be your desired connection string. If you used the normal settings for a new MVC 5 project, and the identity tables do not exist in the new DB they will be created there automatically.

You do not have to edit the portion of the connection string and you do not have to edit the DbContext constructor unless you want to change the conntectionString name and are not OK with replacing the default connection string.

If you are OK with replacing the default connection string, you should be able to just replace it... this worked for me.

I found this article helpful as well: http://www.typecastexception.com/post/2013/10/27/Configuring-Db-Connection-and-Code-First-Migration-for-Identity-Accounts-in-ASPNET-MVC-5-and-Visual-Studio-2013.aspx


The actual question shall be "How do I setup ASP.NET Identity to use my own connection string?"

If above is the correct summary of your question, below is the answer.

ASP.NET Identity uses EntityFramework for database related tasks. So you can use following option as suitable.

Option 1: EntityFramework's default connection string can be setup using following code snippet in web.config

<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
    <parameters>
      <parameter value="Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True" />
    </parameters>
  </defaultConnectionFactory>
</entityFramework>

Option 2: Programatically, you can also pass ConnectionString name to the DbContext's constructor. like new ApplicationDbContext(MyConnectionString)