使用EF 6进行博客数据库设计

时间:2016-10-29 22:52:39

标签: database-design entity-framework-6 blogs

我的Blog应用程序有以下三个表,

public class Blog
 {
    public int Id { get; set; }
    public string Title { get; set; }
    public string ShortDesc { get; set; }
    public string Content { get; set; }
    public DateTime PostedOn { get; set; }
    public DateTime LastUpdatedOn { get; set; }
    public int BloggerId { get; set; }

    [ForeignKey("BloggerId")]
    public virtual Blogger blogger { get; set; }

}
public class Blogger
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string EmailAddress { get; set; }
    public string Country { get; set; }
    public DateTime RegisteredOn { get; set; }
    public int BlogId { get; set; }
    [ForeignKey("BlogId")]
    public List<Blog> BlogList { get; set; }

}

public class Comments
{
    public int Id { get; set; }
    public int BlogId { get; set; }
    public int BloggerId { get; set; }
    public string Comment { get; set; }
    public DateTime PostedOn { get; set; }

    [ForeignKey("BlogId")]
    public virtual Blog blog { get; set; }
    [ForeignKey("BloggerId")]
    public virtual Blogger blogger { get; set; }
}

我的问题是: 我是否必须将我的评论表引用到Blog表中? 如果答案是NO,那么如何查询以获得有一些评论的博客?

0 个答案:

没有答案