Software Dependency

  • Visual Studio 2017
  • Dot Net Core-2.2

In this tutorial will take a look on how to generate the Identity database in dot net core. To know more about what is Identity please check out this official documentation of  Identity.

Step 1.

To Demonstrate i am simply creating Dot Net Core Web API Project as shown.

Once project is Created we need to create Entity framework DBContext object class shown as below. to create DbContext class first we need to install Microsoft.EntityFrameworkCore from Nuget.


Please note we need to inherit DbContext class from IdenityDbContext (in this case i am inheriting my EntityDBContext from IdentityDbContext). Once DbContext class is created we need to configure database settings in Startup.cs shown below

In this tutorial i am using sql server to generate the database. If you want to try with another one you are free to do it :)  e.g postgresql. To access the UseSqlServer method we need to install nuget package Microsoft.EntityFrameworkCore.SqlServer first.

Once you are done with the configuration you need to add migration using command below

ADD-Migration IdentityDemo

Once migration is  done you will get folder named Migration in your project as shown below.

Once migration files generated you need to apply migration on database using

Update-DataBase .

After successful completion of  command you will get the identity table generated in your database like below.