Authentication RRS feed

  • Question

  • User-305496339 posted

    I was just wondering if I could get some help on understanding what this block of code does, specifically : IdentityDbContext<ApplicationUser> . Thanks ! 

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>


            public ApplicationDbContext()

                : base("DefaultConnection", throwIfV1Schema: false)



    Monday, April 23, 2018 11:14 PM


  • User1724605321 posted

    Hi rkrex,

    The ASP.NET MVC 5 templates with Authentication enabled will create a project that contains a class named ApplicationDbContext.

    This is the Entity Framework context used to manage interaction between our application and the database where our Account data is persisted (which may, or may not be the same database that will be used by the rest of our application). Important to note that this class inherits not from DBContext (as is the usual case with EF), but instead from IdentityDbContext. In other words, ApplicationDbContext inherits from a pre-defined DB context defined as part of Microsoft.AspNet.Identity.EntityFramework which contains the “Code-First” base classes for the Identity system.

    Please refer to below links for more details :

    Configuring Db Connection and Code-First Migration for Identity Accounts in ASP.NET MVC 5

    Getting Started with Entity Framework 6 Code First using MVC 5

    Introduction to ASP.NET Identity

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 24, 2018 3:16 AM