- Mastering Entity Framework Core 2.0
- Prabhakaran Anbazhagan
- 116字
- 2021-07-02 21:16:37
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>.
推薦閱讀
- ASP.NET Core 5.0開發入門與實戰
- 華為HMS生態與應用開發實戰
- Web開發的貴族:ASP.NET 3.5+SQL Server 2008
- 機器人Python青少年編程開發實例
- Java加密與解密的藝術
- INSTANT Passbook App Development for iOS How-to
- Getting Started with Gulp
- 焊接機器人系統操作、編程與維護
- Getting Started with React Native
- Hands-On GUI Programming with C++ and Qt5
- QGIS 2 Cookbook
- 青少年學Python(第2冊)
- Java程序設計實用教程(第2版)
- Android嵌入式系統程序開發(基于Cortex-A8)
- 安卓工程師教你玩轉Android