ASP.NET Identity. Part 1 – Changing Default Database

When you create MVC project in Visual Studio 2017, you can use individual user accounts authentication that is shipped with MVC template. This implementation uses Entity Framework. By default, EF creates a database in SQL Server LocalDB with a name like aspnet-WebApp-<timestamp>.

To change the connection to database:
1. Open Web.config file
2. Find section <connectionStrings>
3. Modify the attribute connectionString in element with name DefaultConnection. Element will look like the following:

<add name="DefaultConnection" connectionString="Data Source=(local);Integrated Security=SSPI;Initial Catalog=AspNetIdentityDB;" providerName="System.Data.SqlClient"/>

If you dislike the name DefaultConnection, you should change it in Web.config file and in the constructor of ApplicationDbContext class (file Models\IdentityModels.cs).

Leave a Reply

Your email address will not be published. Required fields are marked *