0

I was created a IdentityUser table and IdentityRoleTable succefully and I can Insert it in both too. even I was created a IdentityUserRole Tables Succefully too but when I want to assign user to the roles that is previously defined it was occure:

Cannot create a DbSet for 'IdentityUserRole' because this type is not included in the model for the context

IdentityUserRole Code :

public class AppUserRole<T>:IdentityUserRole<string> 
{

    public virtual AppUser AppUser { get; set; }
    public virtual AppRole AppRole { get; set; }

}

DataContext Class:

public DbSet<AppUserRole<string>> AppUserRole { get; set; }


    protected override void OnModelCreating(ModelBuilder builder) {
        builder.Entity<AppUserRole<string>>().HasKey(p => new { p.UserId, p.RoleId });
    }
  • 1
    Check this https://stackoverflow.com/questions/52347535/register-aspnetcore-2-1-identity-system-with-dbcontext-interface/52348144#52348144 – Dmitry Pavlov Sep 28 '19 at 21:17
  • oh yes . there is another way to conduct and so much complicated. but it worked –  Sep 29 '19 at 04:40

0 Answers0