Nuget包
Microsoft.EntityFrameworkCore.Tools
使用流程
打开VS中的程序包管理器,选择DBContext 所在的项目
添加迁移文件
Add-Migration (你的迁移文件名称)
执行后:
PM> Add-Migration Add_TestConsole12_Table
Build started...
Build succeeded.
The Entity Framework tools version '6.0.2' is older than that of the runtime '7.0.7'. Update the tools for the latest features and bug fixes. See https://aka.ms/AAc1fbw for more information.
To undo this action, use Remove-Migration.
出现了一个 Migration文件夹,然后里面多了迁移生成的类,以及数据快照
一、使用 Update-DataBase
一定要在DbContext加DBSet,才能和数据库有联系,且账号具有