小编Mar*_*ugu的帖子

EF 6如何将两个外键设置为同一个表

我有一个表UserForms,它有一个States表的两个外键,但在创建我的控制器和创建视图(对于UserForms模型)时,不会出现链接到外键的两个字段.我应该怎么做才能解决这个问题?以下是两种型号:

public class UserForms
{
     public int Id { get; set; }

     public string FullNames { get; set; }
     public Countries IndividualsCountry { get; set; }
     public Countries BusinessCountry { get; set; }
}

public class Countries
{
     public Countries()
     {
         this.STRBusinessCountry = new HashSet<UserForms>();
         this.STRIndividualsCountry = new HashSet<UserForms>();
     }

     public int Id { get; set; }
     public string NameOfCountry { get; set; }

     [InverseProperty("IndividualsCountry")]
     public virtual ICollection<UserForm> STRIndividualsCountry { get; set; }
     [InverseProperty("BusinessCountry")]
     public virtual ICollection<UserForm> STRBusinessCountry { get; …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework

7
推荐指数
1
解决办法
7743
查看次数

标签 统计

c# ×1

entity-framework ×1