@@ -1,12 +1,12 @@
|
||||
|
||||
|
||||
# 构建表名参数列表用于 Scaffold 命令
|
||||
# 构建表名参数列表用于 Scaffold 命令
|
||||
param (
|
||||
[string[]]$Tables
|
||||
)
|
||||
|
||||
|
||||
# 构建表名参数列表
|
||||
# 构建表名参数列表
|
||||
$tablesForScaffold = ""
|
||||
foreach ($table in $Tables) {
|
||||
$tablesForScaffold += "-t $table "
|
||||
@@ -15,15 +15,15 @@ foreach ($table in $Tables) {
|
||||
$tablesForRun = $Tables -join " "
|
||||
|
||||
|
||||
Write-Host "正在执行 Scaffold-DbContext..."
|
||||
Write-Host "正在执行 Scaffold-DbContext..."
|
||||
|
||||
#dotnet ef dbcontext scaffold "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true" Microsoft.EntityFrameworkCore.SqlServer -p IRaCIS.Core.Test -d -o GenerateFolder -c "TempContext" $tablesForScaffold
|
||||
$scaffoldCommand = "dotnet ef dbcontext scaffold `"Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true`" Microsoft.EntityFrameworkCore.SqlServer -p IRaCIS.Core.Test -d -o GenerateContextModelFolder -c `"TempContext`" $tablesForScaffold"
|
||||
Invoke-Expression $scaffoldCommand
|
||||
|
||||
|
||||
Write-Host "正在执行 dotnet run..."
|
||||
Write-Host "正在执行 dotnet run..."
|
||||
#dotnet run --project IRaCIS.Core.Test -- $tablesForRun
|
||||
# 使用 Invoke-Expression 直接执行构造好的命令
|
||||
# 使用 Invoke-Expression 直接执行构造好的命令
|
||||
$runCommand = "dotnet run --project IRaCIS.Core.Test -- $tablesForRun"
|
||||
Invoke-Expression $runCommand
|
||||
@@ -1,29 +1,29 @@
|
||||
|
||||
#参考学习文档
|
||||
#参考学习文档
|
||||
https://www.cnblogs.com/cqpanda/p/16815263.html
|
||||
|
||||
|
||||
# 使用dotnet 命令迁移(dotnet ef dbcontext list -p IRaCIS.Core.Infra.EFCore )
|
||||
# 使用dotnet 命令迁移(dotnet ef dbcontext list -p IRaCIS.Core.Infra.EFCore )
|
||||
|
||||
# dotnet ef migrations add 本地迁移名字 -p 项目名 -c 数据库上下文名 -o 迁移文件生成目录
|
||||
# dotnet ef migrations add 本地迁移名字 -p 项目名 -c 数据库上下文名 -o 迁移文件生成目录
|
||||
|
||||
1、生成迁移文件 (dotnet ef migrations add xxx -s IRaCIS.Core.API -p IRaCIS.Core.Infra.EFCore -c IRaCISDBContext -o CodeFirst_MSSQL/Migrations)
|
||||
1、生成迁移文件 (dotnet ef migrations add xxx -s IRaCIS.Core.API -p IRaCIS.Core.Infra.EFCore -c IRaCISDBContext -o CodeFirst_MSSQL/Migrations)
|
||||
|
||||
dotnet ef migrations add xxx -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
2、撤销生成的迁移文件
|
||||
2、撤销生成的迁移文件
|
||||
|
||||
dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
3、将迁移文件更新到数据库
|
||||
3、将迁移文件更新到数据库
|
||||
|
||||
dotnet ef database update -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
4、以下命令将数据库更新为给定迁移
|
||||
4、以下命令将数据库更新为给定迁移
|
||||
|
||||
dotnet ef database update xxxName -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
5、以下命令将生成一个从指定 from 迁移到指定 to 迁移的 SQL 脚本。
|
||||
5、以下命令将生成一个从指定 from 迁移到指定 to 迁移的 SQL 脚本。
|
||||
|
||||
dotnet ef migrations script from to -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
|
||||
Reference in New Issue
Block a user