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

Blog entity

Create a Blog.cs class file and include the following properties:

    public class Blog
{
public int Id { get; set; }
public string Url { get; set; }
public ICollection<Post> Posts { get; set; }
}

The Entity Framework will look for any property with the name Id or TypeNameId and marks them as the primary key of the table. The Posts property is a navigation property which contains Post items related to this Blog entity. It doesn't matter whether we use ICollection<T> or IEnumerable<T> for the navigation property, EF will create a collection for us, HashSet<T> by default. We could also create a concrete collection using List<T>.

主站蜘蛛池模板: 嘉善县| 海安县| 尚志市| 龙里县| 兴国县| 明光市| 讷河市| 安仁县| 孝义市| 仁怀市| 萝北县| 灵山县| 新余市| 彝良县| 凤山市| 深州市| 武城县| 杂多县| 抚松县| 景东| 石城县| 漯河市| 永宁县| 嵊泗县| 泌阳县| 白水县| 磴口县| 历史| 本溪市| 汪清县| 玉树县| 晋州市| 兰坪| 潞西市| 昆山市| 朝阳市| 新河县| 张掖市| 雷山县| 远安县| 德清县|