Creating a new migration

Every time your model changes, you need to add a new migration to your project. Follow these steps to learn how to do this::

  1. Open the Package Manager Console (Tools | NuGet Package Manager | Package Manager Console).
  2. Type and run the following command:
    Add-Migration [Migration Name] -p [Project Name]
  1. The initial migration in the GiveNTake application was created as follows:
    Add-Migration InitialMigration -p GiveNTake

After the command is complete, a new file will be added to your project under a folder with the name Migrations. The file is named in the [Creation Time]_[Migration Name] format, for example, 20180219101736_InitialMigration.cs.

This file contains a class that derives from Microsoft.EntityFrameworkCore.Migrations.Migration ...

Get Hands-On Full-Stack Web Development with ASP.NET Core 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.