如何使用两个不同的应用程序用户的记录创建模型

时间:2019-01-31 04:23:58

标签: c# entity-framework

我正在尝试允许asp.net mvc应用程序中的两个用户形成关系。我还想使用虚拟扩展名来访问每个用户的字段集。

public class Connection
{
    [Key]
    public int ConnectionId { get; set; }
    public int UserId { get; set; }
    public int UserId2 { get; set; }        

    [StringLength(128), MinLength(3)]
    [ForeignKey("UserId")]
    public virtual ApplicationUser User { get; set; }

    [StringLength(128), MinLength(3)]
    [ForeignKey("UserId2")]
    public virtual ApplicationUser User2 { get; set; }
}

我意识到上面的方法不起作用,因为第二个外键不正确,但是我把它留在了我要显示的位置。我该怎么做?

0 个答案:

没有答案
相关问题