Chapter 8 - Working with Databases Using Entity Framework Core

  1. Which .NET data provider would you use to work with Microsoft SQL Server 2012 Express Edition?
    • .NET Core Data Provider for SQL Server.
  2. When defining a DbContext class, what type would you use for the property that represents a table, for example, the Products property?
    • DbSet<T>, where T is the entity type, for example, Product.
    • For a Products property on another entity, for example, Category, that represents a one-to-many relationship between entities, use ICollection<T>, where T is the related entity type.
  3. What is the EF convention for primary keys?
    • 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, int, bigint, guid.
  4. When would you use an annotation attribute in an entity class?
    • You would use an annotation attribute in an entity class when the conventions cannot work out the correct mapping between the classes and tables. For example, if a class name does not match a table name or a property name does not match a column name.
  5. Why might you choose fluent API in preference to annotation attributes?
    • You might choose fluent API in preference to annotation attributes when the conventions cannot work out the correct mapping between the classes and tables, and you do not want to use annotation attributes because you want to keep your entity classes clean and free from extraneous code.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.6.10