相关疑难解决方法(0)

如何使用集合

任何人都可以写迷你指南,解释如何使用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)

c# entity-framework entity-framework-core

9
推荐指数
1
解决办法
2617
查看次数