- 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>.
推薦閱讀
- Puppet 4 Essentials(Second Edition)
- ServiceNow Application Development
- Mastering Zabbix(Second Edition)
- 案例式C語言程序設(shè)計
- Magento 2 Theme Design(Second Edition)
- Mastering Python Scripting for System Administrators
- PHP 編程從入門到實踐
- Scratch 3游戲與人工智能編程完全自學(xué)教程
- 概率成形編碼調(diào)制技術(shù)理論及應(yīng)用
- Mastering JBoss Enterprise Application Platform 7
- Java Web開發(fā)詳解
- Swift High Performance
- 小學(xué)生C++趣味編程從入門到精通
- Web程序設(shè)計與架構(gòu)
- Elasticsearch實戰(zhàn)(第2版)