ef core 数据迁移命令

PM> Add-Migration init    生成迁移文件
To undo this action, use Remove-Migration.
PM> Update-Database init
Applying migration '20170917062429_init'.
Done.
--------每次改动生成 PM> Add-Migration updatedb To undo this action, use Remove-Migration. PM> Update-Database updatedb Applying migration '20170917063252_updatedb'. Done. PM>

update-database migrationName,也相当于版本回滚操,比如有版本1,2,3 此时我想回滚到版本1就直接 update-database 1,
此时数据库中已经更新到1版本了,然后在两次remove-migration把2和3的迁移文件删除就好了

生成脚本 UpdateColumn 到 111的脚本

Script-Migration -From UpdateColumn -To 111

猜你喜欢

转载自www.cnblogs.com/zengk/p/10256542.html