我尝试像这样自定义IdentityUserRole
public partial class MyUserRoles : IdentityUserRole
{
pulic bool isAdminUser{set;get;}
}
之后我想添加一个对象
{
...
MyUserRoles userRole=new MyUserRoles();
userRole.UserId = user.Id;
userRole.RoleId = rolemanager.id;
userRole.isAdminUser = true;
}
我的问题是如何将此userRole添加到userRoleTable
答案 0 :(得分:0)
public class ApplicationDbContext : IdentityDbContext<SecuHostUser>
{
public ApplicationDbContext()
: base("SecuHostEntitiesSecurity")
{
}
new public DbSet<MyUserRoles> UserRoles { set; get; }
}
ApplicationDbContext context= new ApplicationDbContext();
context.UserRoles.Add(userRole);
context.savechange