我正在使用Code First方法,我设计了以下类。
public interface IItem
{
public Guid ItemId { get; set; }
DateTime? CreateDate { get; set; }
DateTime? ModifyDate { get; set; }
User CreatedBy { get; set; }
User ModifiedBy { get; set; }
}
public class User : IItem
{
public string Email { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Name { get; set; }
public Guid ItemId { get; set; }
public DateTime? CreateDate { get; set; }
public DateTime? ModifyDate { get; set; }
public User CreatedBy { get; set; }
public User ModifiedBy { get; set; }
}
public class Entity1 : IItem
{
public string Entity1Prop1 { get; set; }
public Guid ItemId { get; set; }
public DateTime? CreateDate { get; set; }
public DateTime? ModifyDate { get; set; }
public User CreatedBy { get; set; }
public User ModifiedBy { get; set; }
}
现在我需要使用流畅的API定义实体之间的关系。 我有以下要求 1.用户表具有主键ItemId 2.用户表colulmns CreatedBy和ModifiedBy引用相同的用户表ItemId列作为ForeignKey 3. Entity1表具有主键ItemId 4.实体表列CreatedBy和ModifiedBy引用用户表itemId作为外键