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; set; }
public DbSet<Quiz> Quizzes { get; set; }

[...]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.137.58