Database migration mode: PMC (Package Management Controller), CLI (the directory console operation where the program resides)
1: Configure database information in Appsetting.json before migrating the database
Note: both the entityframeworkcore.tools and Entityframeworkcore.sqlserver plugins are introduced on the NuGet Package Manager .
2:CLI Database Migration
A: You first need to add a reference to the library in the project file
<dotnetclitoolreference include= "Microsoft.EntityFrameworkCore.Tools.DotNet" version= "2.0.2"/>
The version number depends on the actual situation of your project.
B: In the control form where the project is located, enter the command dotnet EF migrations Add initalcreate,initalcreate can be arbitrarily named. After executing this line, the Migrations folder will be found in the project.
The generated file data is inside, the Initalcreate file has two rewrite methods up, Down,up represents the transferred data form, DOWNB represents the data form before the transfer
C: Now you need to build the database, execute the command dotnet EF database update
Note: If there is no problem with the above steps, the database has been generated. But if there is a problem, please pay attention to whether the lack of reference, Baidu solve it yourself.
2:PMC (Package Management Controller)
This is relatively simple.
A: Find package management Controller
B: In the console input command: Add-migration in the name of the random input English name update-database
Note: If the database has been generated successfully without error, if there is a problem
If you have any shortcomings, please advise friends, thank you ...
Migration of. Net Core databases