在asp身份中是否有任何IdentityUserRole商店

时间:2014-03-18 01:38:56

标签: asp.net visual-studio-2013

我尝试像这样自定义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

1 个答案:

答案 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