EntityFrameworkCore学习
文章目录
1.EF Tool安装(更新)命令
1.1安装
dotnet tool install --global dotnet-ef
1.1更新
dotnet tool update --global dotnet-ef
2.CodeFirst
1.添加迁移
dotnet ef migrations add
2.删除迁移
dotnet ef migrations remove
3.获取两次迁移sql语句
dotnet ef migrations script <PreviousMigration> <LastMigration>
4.列出可用的迁移
dotnet ef migrations list
5.更新数据库
dotnet ef database update
6.删除数据库
dotnet ef database drop
3.DbFirst
为 DbContext 生成代码,并为数据库生成实体类型。 为了让此命令生成实体类型,数据库表必须具有主键
dotnet ef dbcontext scaffold
4.切换环境
$env:ASPNETCORE_ENVIRONMENT='Production'