如何在这里将外键与不同的名称相关联:post中的createdby和 users 表中的UserID。
public class Post : IValidatableObject
{
[Key]
public long PostID { get; set; }
public long? ParentPostID { get; set; }
[ForeignKey("CreatedBy")]
public virtual User Users { get; set; }
[ScaffoldColumn(false)]
public DateTime? CreatedDate { get; set; }
[ScaffoldColumn(false)]
public long? CreatedBy { get; set; }
}
public class User
{
[Key]
public long UserID { get; set; }
[Required]
[MaxLength(20)]
[Display(Name = "User Name")]
public string UserName { get; set; }
}