2012-08-29 39 views
0

我有以下类别:的EntityFramework创建额外的列

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; } 
} 

的用户表中生成正常,但订阅表是这样的:

Subscriptions(SubscriptionId, status, Follower_UserId, Followed_UserId, 
User_UserId, User_UserId1) 

这最后两个栏都没有necesary他们实际上是NULL值

+1

这些列是映射所必需的。问题是列名没有意义。 – Eranga

回答

2

尝试使用此:

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; } 
} 
+0

非常感谢! – sports