- 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>.
推薦閱讀
- Python量化投資指南:基礎(chǔ)、數(shù)據(jù)與實戰(zhàn)
- PostgreSQL Cookbook
- Solr Cookbook(Third Edition)
- 用案例學(xué)Java Web整合開發(fā)
- TMS320LF240x芯片原理、設(shè)計及應(yīng)用
- AutoCAD 2009實訓(xùn)指導(dǎo)
- 21天學(xué)通C++(第5版)
- Building Wireless Sensor Networks Using Arduino
- Advanced UFT 12 for Test Engineers Cookbook
- Vue.js光速入門及企業(yè)項目開發(fā)實戰(zhàn)
- 跟戴銘學(xué)iOS編程:理順核心知識點
- 算法秘籍
- Mastering Embedded Linux Programming
- 自己動手構(gòu)建編程語言:如何設(shè)計編譯器、解釋器和DSL
- SOA Patterns with BizTalk Server 2013 and Microsoft Azure(Second Edition)