Modifying the Data Model

Learn how to make modifications to an existing project using the Code First workflow.

Overview

In this lesson, we’ll see how migrations enable us to modify the model. We’ll perform the following actions:

  • Add a new entity type to a model.
  • Add a new property to an entity type.
  • Rename a property of an entity type.
  • Delete a property of an entity type.

Note: The commands in this lesson generate code and files. Through the terminal, we can navigate to these files by using relevant Linux commands such as ls to view a list of files and directories, cd to change directories, and cat to view file contents. A SPA widget showing the updated project with the generated files is also available. Also, note that EF Core uses a timestamp within the generated file names, which we represent with xxx.

Adding a new entity type to a model

In this project, the Entities directory contains a new entity named SeniorityLevel. This entity enables us to categorize employees based on their experience.

Get hands-on with 1200+ tech skills courses.