Creating migrations with EF Core
Using EF Core, you can create the database with the Database.EnsureCreatedAsync
context API method. However, this does not take schema changes into account. Over time, the database schema will change as new features are added – and it’s best to do this automatically.
Chapter 8 describes how to automatically publish services to testing and production environments. With this, updating the database is important as well. When the database schema changes, updates should be published to the environments. EF Core offers migrations to record all schema changes and update the database schema programmatically.
Next, let’s do the following:
- Add the .NET EF Core tool
- Add the EF Core tool and create initial migrations
- Update the model and add migrations
- Update the database programmatically
Adding the .NET EF Core tool
If you don’t have the EF Core .NET command-line tool installed yet, you can install...