.netCore数据库迁移

程序包管理器控制台下Nuget

命令:
初始迁移命令:
add-migration init -Context DAL.ProductContext
全称:migrations add InitialCreate
非第一次迁移:
migrations add 迁移日志名称
例如:
add-migration AddRowVersion
更新到数据库:
update-database -Context DAL.ProductContext

  

Powershell方式下命令(同Mac,vscode)

初始迁移命令:
dotnet ef migration add initialmigration -s ../ASP.NetCoreAPI
格式:dotnet ef migration add initialmration -s 包含配置文件的项目
非第一次迁移:
dotnet ef migrations add 迁移日志名称 -s 包含配置文件的项目
例如:
dotnet ef migrations add ThisIsLiYuqis -s ../ASP.NetCoreAPI
更新到数据库:
dotnet ef database update

  

原文地址:https://www.cnblogs.com/xiaoliangge/p/8033008.html