Entity framework EntityFramework创建额外列
我有以下课程:Entity framework EntityFramework创建额外列,entity-framework,Entity Framework,我有以下课程: public partial class User { [Key] public int UserId { get; set; } public string Username { get; set; } [ScriptIgnore] public virtual ICollection<Subscription> Followers { get; set; } [ScriptIgnore] public vir
public partial class User
{
[Key]
public int UserId { get; set; }
public string Username { get; set; }
[ScriptIgnore]
public virtual ICollection<Subscription> Followers { get; set; }
[ScriptIgnore]
public virtual ICollection<Subscription> Following { get; set; }
}
public partial class Subscription
{
[Key]
public int SubscriptionId { get; set; }
public virtual User Follower { get; set; }
public virtual User Followed { get; set; }
public int status { get; set; }
}
最后两列不是必需的,它们实际上得到的是空值
public partial class Subscription
{
[Key]
public int SubscriptionId { get; set; }
[InverseProperty("Followers")]
public virtual User Follower { get; set; }
[InverseProperty("Following")]
public virtual User Followed { get; set; }
public int status { get; set; }
}
这些列是映射所必需的。问题是列名没有意义。我也有类似的问题,在这里解释。不知道为什么它会添加额外的列。在属性ResponseId上尝试使用[InverseProperty(“ResponseId”)]。不适合我
public partial class Subscription
{
[Key]
public int SubscriptionId { get; set; }
[InverseProperty("Followers")]
public virtual User Follower { get; set; }
[InverseProperty("Following")]
public virtual User Followed { get; set; }
public int status { get; set; }
}