Supporting code-first in Entity Framework Core, Entity Framework Core provides us with a migration function: to keep our database architecture design in sync with the application's model classes (also called entity classes). Only need to pay attention to the realization of business logic, the database will help us build it automatically.
Open the console
This is the code automatically generated by efcore for us
Check out the database
But we found that this is an empty table, because we did not give the initial data
Override methods in DbContext
Add the required data and then
For the readability and maintainability of the code, the initialization seed can be extracted to write an extension method