Upgrading the DbContext

In order to support the ASP.NET Core Identity service, our ApplicationDbContext class needs to be updated as well.

Open the Data/ApplicationDbContext.cs class file and perform the following changes:

  1. Add a using reference to Microsoft.AspNetCore.Identity.EntityFrameworkCore, as required by the new base class:
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 
  1. Change the base class from DbContext to IdentityDbContext<ApplicationUser>:
[...]public class ApplicationDbContext : IdentityDbContext<ApplicationUser> [...]
  1. Remove the DbSet<ApplicationUser> Users property, as the IdentityDbContext base class that we just inherited already has it built in:
[...]#region Properties// public DbSet<ApplicationUser> Users ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.