Set The Stage
So let’s set the what and why we will be doing. Our fictitious company, Apothecaric Consulting is a small consulting firm with a few employees and a few subcontractors. Apothecaric would like to create an application for employees and subcontractors to submit timesheets for the projects they are working on. Apothecaric would also like to be able to add more applications in the future but they don’t want to have to create a new login system for the new applications. If a user is logged in, they should have access to all the Apothecaric applications that they may have access to.
So Apothecaric Consulting is a small firm and don’t really have a central office. They also do not have a robust network or Active Directory or any other type of user store/directory.
That leaves us with storing user information in a custom datastore of some sort. Here is where we start with using Asp.Net Identity and the database that it creates.
Create the Project
We will start by creating a default, Asp.Net MVC application. Just the defaults here. We will only use this project to get an Asp.Net Identity database created for us. We don’t even have to run or even compile this project.
I won’t go through the detail here….just create an Asp.Net MVC project using the standard template in Visual Studio 2015 and accept all the defaults.
Database Name
I don’t want to keep the default database name that Asp.Net Identity will provide. In addition, I don’t want to have my database created in the App_Data folder either. For development, we have a Sql Server Express instance where we want to create our Identity database in.
This is an easy fix. Let’s look at our web.config file.
Find the connectionString tag…
Notice that crazy name listed in the Initial Catalog. I would like to use something friendlier than that. Lets make a few changes….
There, that is much better. I am now pointing to my local Sql Server Express instance, the database name will now be something much more meaningful and no need for the AttachDbFilename.
That is all there is to changing the database name that Asp.Net Identity will create for us. No build yet…we will get to that.
Next, let’s look at adding a couple of fields to the AspNetUsers table that will get created by AspNet Identity.