代码之家  ›  专栏  ›  技术社区  ›  barii

.NET身份用户,用户分离

  •  0
  • barii  · 技术社区  · 8 年前

    我的用户具有与身份验证相关的属性。例如,电子邮件地址、密码、用户有权访问的项目等。

    • 因为颜色与身份验证无关,所以我不想将颜色添加为ApplicationUser:IdentityUser{}的属性。

    • 但不知何故,我需要将值写入该字段,这样我就可以编写一个存储库,它接受常规用户对象。但是在这种情况下,我需要编写存储库,自己散列密码,那么拥有.NET标识有什么意义呢?

    • 我能想到的另一个想法是让ApplicationUser:IdentityUser{}基本上是User的一个副本(我也不能从User和IdentityUser继承,也不能链接它,因为首先是数据库),并且在auth中有一个单独的AuthenticationUser:IdentityUser。上下文

    我该怎么做?

    1 回复  |  直到 8 年前
        1
  •  0
  •   user229044    7 年前

    我认为对于这个问题,您必须改变您的模型,如:

    public class Person
    {
        public string Color { get; set: }
        public int RoleId { get; set: }
        public Role Role { get; set: }
    
        public ICollection<UserAuthentication> UserAuthentications { get; set: }
    }
    
    public class UserAuthentication
    {
        public Person Person { get; set: }
        public int PersonId { get; set: }
    }
    

    如果您有任何数据,可以使用 TSql .