In the course of project development, it is often encountered when the project is released and changes the database. How is it easy to migrate a database?
The following steps directly list the actions:
1. post the modified app :
Update the latest version of the app to the target machine. The updated file certainly does not include the database.
When you run the app, an error message appears:
Models that support the "Abpzerotemplatedbcontext" context have changed since the database was created. Consider migrating the update database using Code first
Indicates that our database needs to be updated.
2. Copy Migration Tool :
Copy the Migrate.exe under our project folder to the target machine.
SOURCE files: < Project folders >\packages\EntityFramework.< version >\tools\migrate.exe, such as C:\project-Epmp\packages\ Entityframework.6.1.3\tools\migrate.exe
Target directory: < publish folder >\bin, such as D:\project-Epmp\publish\bin
Target Machine Bin directory, there should be files EntityFramework.dll, etc.
3. execute the Migration command :
At the command prompt, execute the following command (database connection takes SQL Server as an example)
Migrate.exe xxx.yyy.entityframework.dll/connectionstring="server=localhost;database= database name; user= user name; password= user password; "/connectionprovidername="System.Data.SqlClient "
If the execution goes smoothly, the "Applying display migration ..." will be displayed. and other information.
Well, it's the end of the migration.
After you open the updated app, it should work.
Lakes ABP-Migrating Codefirst databases after system release [original]