• EF Core相关工具使用


    1、安装ef tools

    首先确保本地netcore sdk安装完毕,如下是卸载tool、安装指定版本tool、更新到指定版本的tool 的命令:

    dotnet tool uninstall --global dotnet-ef
    dotnet tool install --global dotnet-ef --version 5.0.0
    dotnet tool update --global dotnet-ef --version 5.0.5

    2、在目标项目安装Microsoft.EntityFrameworkCore.Tools nuget包 

    3、定位到指定项目解决方案下(..csproj文件不是sln) 让cmd工作目录定位到当前目录

    4、迁移dbcontext

    dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb

    5、更新到数据库

    dotnet ef database update --context PersistedGrantDbContext

    6、删除指定上下文对应的数据库(慎用)

    dotnet ef database drop --context PersistedGrantDbContext

    7、为迁移创建sql脚本

    dotnet ef migrations script 0  20220510070558_InitialIdentityServerPersistedGrantDbMigration --context PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb/1.sql

    注意:指令中的script 0 代表为20220510070558_InitialIdentityServerPersistedGrantDbMigration创建迁移脚本,如果不加0,如下:

    dotnet ef migrations script 20220510070558_InitialIdentityServerPersistedGrantDbMigration --context PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb/1.sql

    则代表为20220510070558_InitialIdentityServerPersistedGrantDbMigration之后的迁移创建迁移脚本.

     dotnet tool update --global dotnet-ef
  • 相关阅读:
    第08组 Alpha冲刺(3/6)
    第08组 Alpha冲刺(2/6)
    第08组 Alpha冲刺(1/6)
    第08组 团队Git现场编程实战
    第08组 团队项目-需求分析报告
    网站是如何管理的
    拆机总结引发的组装指南
    计算机启动出现 Invalid Partition Table
    ARP 询问之 校级路由器的猫腻
    网络攻击形式备忘录
  • 原文地址:https://www.cnblogs.com/GreenLeaves/p/16253771.html
Copyright © 2020-2023  润新知