Model view controller Autofac和自定义应用程序角色
我需要将与另一个表的关系添加到我的AspNetRoles表中 因此,在我的mvc应用程序中,我为新实体创建了一个新模型和一个自定义角色模型,如下所示:Model view controller Autofac和自定义应用程序角色,model-view-controller,asp.net-identity,autofac,Model View Controller,Asp.net Identity,Autofac,我需要将与另一个表的关系添加到我的AspNetRoles表中 因此,在我的mvc应用程序中,我为新实体创建了一个新模型和一个自定义角色模型,如下所示: [Table("PermissionRecord")] public class PermissionRecordModel { public PermissionRecordModel() { Roles = new HashSet<Applica
[Table("PermissionRecord")]
public class PermissionRecordModel
{
public PermissionRecordModel()
{
Roles = new HashSet<ApplicationRole>();
}
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
[StringLength(255)]
public string SystemName { get; set; }
[Required]
[StringLength(255)]
public string Category { get; set; }
public virtual ICollection<ApplicationRole> Roles { get; set; }
}
[表(“许可记录”)]
公共类许可记录模型
{
公共许可记录模型()
{
Roles=newhashset();
}
[数据库生成(DatabaseGeneratedOption.None)]
公共int Id{get;set;}
[必需]
公共字符串名称{get;set;}
[必需]
[StringLength(255)]
公共字符串SystemName{get;set;}
[必需]
[StringLength(255)]
公共字符串类别{get;set;}
公共虚拟ICollection角色{get;set;}
}
公共类应用程序角色:IdentityRole
{
公共应用程序角色()
{
PermissionRecord=新哈希集();
}
公共应用程序角色(字符串roleName):基本(roleName)
{
}
公共虚拟ICollection PermissionRecord{get;set;}
}
我已经将Autofac与自定义ApplicationUser一起使用了,一切都很好,但我找不到使用自定义ApplicationRole model的方法。。。查看所有内容并进行大量更改以找到解决方案
有人成功了吗
谢谢 这里没有足够的答案来回答这个问题。我不确定Autofac与ASP.NET身份有什么关系,没有解释“工作”与“不工作”的含义,也没有解释。不幸的是,这意味着你不太可能得到你所寻求的帮助。我建议你用更多的信息更新这个问题。
public class ApplicationRole : IdentityRole
{
public ApplicationRole()
{
PermissionRecord = new HashSet<PermissionRecordModel>();
}
public ApplicationRole(string roleName) : base(roleName)
{
}
public virtual ICollection<PermissionRecordModel> PermissionRecord { get; set; }
}