December 2019
Intermediate to advanced
494 pages
11h 41m
English
One very awesome feature of EF is migrations, which allow you to write your code and then automatically generate your database accordingly. So, let's add another table to the database using migrations.
Before we do anything, we need to install the Microsoft.EntityFrameworkCore.Tools package using NuGet. After that, we need to tell EF that we've already created the Person table so that it doesn't try to create it all over again. Go into the package manager console and run the following command:
Add-Migration InitialCreate
This creates a folder in your project called migrations and adds a file named [date_and_time]_InitialCreate.cs. Open this file and empty the Up and Down methods. Now, EF won't try to create (or ...