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

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.

主站蜘蛛池模板: 新昌县| 富锦市| 永嘉县| 盐津县| 阳谷县| 都江堰市| 华容县| 南充市| 肇庆市| 曲松县| 宜城市| 黑水县| 芜湖县| 宜黄县| 大宁县| 莱州市| 珲春市| 五原县| 浠水县| 侯马市| 肃宁县| 阳东县| 漠河县| 罗田县| 邛崃市| 新竹县| 杭州市| 星子县| 凤冈县| 区。| 元谋县| 高尔夫| 新平| 忻州市| 福安市| 仙居县| 雅安市| 偃师市| 阜城县| 忻城县| 大埔区|