任何人都可以写迷你指南,解释如何使用EF中的集合吗?
例如,我有以下模型:
public class BlogPost
{
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public DateTime DateTime { get; set; }
public List<PostComment> Comments { get; set; }
}
public class PostComment
{
public int Id { get; set; }
public BlogPost ParentPost { get; set; }
public string Content { get; set; }
public DateTime DateTime { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和上下文类:
public class PostContext : …Run Code Online (Sandbox Code Playgroud)