Chapter 11 – Working with Databases Using Entity Framework Core

  1. What type would you use for the property that represents a table, for example, the Products property of a Northwind database context?

Answer: DbSet<T>, where T is the entity type, for example, Product.

  1. What type would you use for the property that represents a one-to-many relationship, for example, the Products property of a Category entity?

Answer: ICollection<T>, where T is the entity type, for example, Product.

  1. What is the EF convention for primary keys?

Answer: The property named ID or ClassNameID is assumed to be the primary key. If the type of that property is any of the following, then the property is also marked as being an IDENTITY column: tinyint, smallint,

Get C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.