EF Core dotnet-ef 常用命令,指令
目录
一、当前安装dotnet-ef 版本查看
dotnet-ef --version
二、dotnet-ef 所有版本查看
版本查看地址:https://www.nuget.org/packages/dotnet-ef
三、dotnet-ef 版本切换
dotnet tool uninstall --global dotnet-ef
dotnet tool install --global dotnet-ef --version 5.0.0
四、dotnet-ef 模型更新
1) 生成所有表模型
dotnet ef dbcontext scaffold "Server = ***;Database = YESDotnet;User ID = garson;Password =***;Trusted_Connection = False" Microsoft.EntityFrameworkCore.SqlServer --output-dir "Tables" --no-onconfiguring --no-pluralize --use-database-names --force --data-annotations --context-dir "Entities" --context-namespace "YESWEB.Module.DengSystemDB" --context "_EntitiesContext"
2) 生成指定表模型
dotnet ef dbcontext scaffold "Server = ***;Database = YESDotnet;User ID = garson;Password =***;Trusted_Connection = False" Microsoft.EntityFrameworkCore.SqlServer --output-dir "Tables" --table "dt_data1" --table "dt_data2" --table "dt_data3" --no-onconfiguring --no-pluralize --use-database-names --force --data-annotations --context-dir "Entities" --context-namespace "YESWEB.Module.DengSystemDB" --context "_EntitiesContext"
五、dotnet-ef 生成数据库迁移脚本
dotnet ef migrations add V001 --context EntitiesContext --project "..\YESWEB.Module.DengSystemDB" --startup-project "..\_DBContextScaffold.Start"
六、配置数据库连接机密,机密管理
初始化机密配置
dotnet user-secrets init
配置机密 数据库连接字符串
dotnet user-secrets set ConnectionStrings.GZSales "Data Source=***;User Id=***;Password=***;Initial Catalog=GZSales"
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post YES开发框架