0
有兩個實體Post
和Photo
。兩者都有一個comment
實體的集合。多個父實體首先在EF代碼中有一個子實體
反正是有避免mapping
以下書面(即已經以限定一個屬性每個父在Comment
實體)?
public class Post
{
public string Title {get; set;}
public ICollection<Comment> Comments{get; set; }
}
public class Photo
{
public string Path{get;set;}
public ICollection<Comment> Comments{get; set; }
}
public class Comment
{
public int? PostId{get;set;}
public Virtual Post Post{get;set;}
public int? PhotoId{get;set;}
public Virtual Photo Photo{get;set;}
}