Modifying the Data Model
Explore how to modify data models with Entity Framework Core migrations. Learn to add new entities, add or rename properties, and delete properties within your model, keeping the database in sync with code changes using migration commands.
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
lsto view a list of files and directories,cdto change directories, andcatto 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 withxxx.
Adding a new entity type to a model
In this project, the Entities directory contains a new entity named ...