I am trying to get user list with their co responding Roles. Using IdentityUser, IdentityRole, IdentityUserRole. I have already tried different way and followed many Answer from StackOverflow. The main issue I have, when I add Navigation property to User and Role models then in UserRole table duplicate some columns.
Please let me know if you need more informations
But I need your help.
Details: User:
public class User : IdentityUser
{
public string Gender { get; set; }
public ICollection<UserRole> UserRoles { get; set; }
}
Role:
public class Role : IdentityRole<string>
{
public ICollection<UserRole> UserRoles { get; set; }
}
UserRole:
public class UserRole : IdentityUserRole<string>
{
public User User { get; set; }
public Role Role { get; set; }
}
DbContext:
public class DataContext : IdentityDbContext<User, Role, string, IdentityUserClaim<string>,
UserRole, IdentityUserLogin<string>, IdentityRoleClaim<string>, IdentityUserToken<string>>
{
public DataContext(DbContextOptions<DataContext> options) : base(options) {}
}
After Migration and Updating database: Table AspNetUserRoles:
ps: Those data inserted before.
I getting frustrated, Please help