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

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.

主站蜘蛛池模板: 千阳县| 松溪县| 永泰县| 黔西县| 双鸭山市| 临高县| 临安市| 莒南县| 久治县| 青龙| 南投市| 尉犁县| 乐都县| 旺苍县| 牟定县| 库车县| 南木林县| 筠连县| 灵山县| 利川市| 南汇区| 玉龙| 南澳县| 安远县| 禄劝| 资溪县| 枞阳县| 理塘县| 若羌县| 嵊泗县| 玉门市| 朝阳市| 雷州市| 靖州| 牡丹江市| 叙永县| 玉龙| 郁南县| 襄汾县| 宜川县| 武安市|