Open the nuget package management console and enter: Enable-migrations Press enter. If yes, code first migration is enabled for project XXX. Here are several possible errors: 1.no context type was found in the Assembly XXX does not find the database context in the current project, that is, the database inherited by dbcontext. CS "2.The entityframework package is not installed on Project XXX the current project has found the data context, but no entityframework requires installation and input install-package entityframework) if the installation is successful, the migrations folder appears in the project, which records the changes in each data migration. It is very easy to use, and there is no need to delete the database to regenerate data loss and other issues. Common statement: Enable-migrations-force replace migration data file update-database update add-migration add new update File
EF console Common commands