The type ApplicationUser cannot be used as type parameter 'TUser' in the generic type or method 'IdentityDbContext'

后端 未结 1 1920
遥遥无期
遥遥无期 2021-02-15 13:41

Trying to implement Identity in ASP.NET Core 2.0. Having many problems getting my head around this.

Startup.cs

public class Startup
{
          


        
相关标签:
1条回答
  • 2021-02-15 14:13

    Change public class ApplicationDbContext : IdentityDbContext<ApplicationUser> to

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid>
    

    You will need to have an ApplicationRole class similar to you ApplicationUser class. From what I remember once you specify the key type (in this case Guid, the default being string) you need to include the role and the key type even if you are not using roles.

    0 讨论(0)
提交回复
热议问题