官术网_书友最值得收藏!

Working with the Blog entity

We have discussed in detail the Blog model in Chapter 1Kickstart - Introduction to Entity Framework Core, but still, the following highlighted part looks pretty new to us:

  • The Blog() constructor initializes the Post property, which ensures that the collection has a concrete HashSet list created and ready to accept any new items
  • The Post property has a virtual keyword, which instructs EF to lazy load the navigational property Post:
        public partial class Blog
{
public Blog()
{
Post = new HashSet<Post>();
}
public int Id { get; set; }
public string Url { get; set; }
public virtual ICollection<Post> Post { get; set; }
}

There is nothing much to explore in the Blog class so, let's move on to the Post class.

主站蜘蛛池模板: 开江县| 广宗县| 金溪县| 宁武县| 巴塘县| 文昌市| 大竹县| 通山县| 尉氏县| 成都市| 巴南区| 揭阳市| 那坡县| 揭西县| 郓城县| 沛县| 南投市| 靖远县| 渝北区| 苏尼特右旗| 汾西县| 双峰县| 敖汉旗| 和硕县| 丹阳市| 河北省| 昭觉县| 辛集市| 茌平县| 福州市| 延吉市| 峨眉山市| 嘉善县| 青岛市| 定日县| 正蓝旗| 阿拉善盟| 中山市| 清流县| 临邑县| 淮滨县|