December 2019
Intermediate to advanced
510 pages
11h 33m
English
EF Core encourages the code-first approach in our services. The code-first technique consists of defining some entity classes in C# and using them to generate tables on the database side. The same approach is applied to all the relationships and constraints that are usually present in a SQL ecosystem, such as the index, the primary keys, and the foreign keys. This section demonstrates how to use this kind of approach to generate the database schema.
First of all, let's start by taking back our Item.cs entity and adding an ID that represents the relationship with the other entities:
using System;namespace Catalog.Domain.Entities{ //Item.cs file public class Item { public Guid Id { get; set; } public ...