migration命令需要安装Microsoft.EntityFrameworkCore.Tools
dotnet add package Microsoft.EntityFrameworkCore.sqlserver --version 5.0.13
dotnet add package Microsoft.EntityFrameworkCore.Tools --version 5.0.13
migration命令
add-migration init
update-database stateX -- update db to stateX
remove-migration
生成sql script
script-migration
- script-migration v1 // generate sql script from v1 (exclude v1) to latest
- script-migration v1 v2 // generate sql script from v1 to v2
逆向生成C#代码
scaffold-dbcontext // generate entity class from db
- scaffold-dbcontext %connstr% microsoft.entityframeworkcore.sqlserver