Populating the database

Now that we have a SQL Database available and a DbContext that we can use to read from and write to it, we are finally ready to populate those tables with our world cities data.

To do that, we need to implement a data seeding strategy. We can do this using one of the various Entity Framework Core-supported approaches:

  • Model data seed
  • Manual migration customization
  • Custom initialization logic

These three methods are well-explained in the following article, along with their very own sets of pros and cons: https://docs.microsoft.com/en-us/ef/core/modeling/data-seeding.

Since we have to handle a relatively big Excel file, we're going to adopt the most customizable pattern we can make use of: some custom initialization ...

Get ASP.NET Core 3 and Angular 9 - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.