

# 构建表名参数列表用于 Scaffold 命令
param (
    [string[]]$Tables
)


# 构建表名参数列表
$tablesForScaffold = ""
foreach ($table in $Tables) {
    $tablesForScaffold += "-t $table "
}

$tablesForRun = $Tables -join " "


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..."
#dotnet run --project IRaCIS.Core.Test -- $tablesForRun
# 使用 Invoke-Expression 直接执行构造好的命令
$runCommand = "dotnet run --project IRaCIS.Core.Test -- $tablesForRun"
Invoke-Expression $runCommand