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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.