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

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.

主站蜘蛛池模板: 合作市| 施秉县| 蕲春县| 牙克石市| 普兰县| 辛集市| 池州市| 寿光市| 盐亭县| 临沧市| 玉林市| 咸阳市| 察隅县| 平舆县| 安达市| 海安县| 柳林县| 共和县| 全州县| 绩溪县| 兰州市| 合江县| 拜泉县| 蓝田县| 罗山县| 佳木斯市| 桑日县| 景德镇市| 抚宁县| 安国市| 阳东县| 昌黎县| 雅安市| 洛南县| 巢湖市| 德令哈市| 兴安县| 康马县| 武乡县| 嘉祥县| 南江县|