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

后端 未结 1 1774
后悔当初
后悔当初 2021-02-15 13:33

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:20

    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)
提交回复
热议问题