# 数据库迁移脚本 Write-Host "开始执行数据库迁移..." -ForegroundColor Green try { # 添加迁移 Write-Host "正在添加迁移..." -ForegroundColor Yellow dotnet ef migrations add UpdateAppUserAuditFields --project src/CellularManagement.Infrastructure --startup-project src/CellularManagement.WebAPI if ($LASTEXITCODE -eq 0) { Write-Host "迁移添加成功!" -ForegroundColor Green # 更新数据库 Write-Host "正在更新数据库..." -ForegroundColor Yellow dotnet ef database update --project src/CellularManagement.Infrastructure --startup-project src/CellularManagement.WebAPI if ($LASTEXITCODE -eq 0) { Write-Host "数据库更新成功!" -ForegroundColor Green } else { Write-Host "数据库更新失败!错误代码: $LASTEXITCODE" -ForegroundColor Red exit 1 } } else { Write-Host "迁移添加失败!错误代码: $LASTEXITCODE" -ForegroundColor Red exit 1 } } catch { Write-Host "执行过程中发生错误:" -ForegroundColor Red Write-Host $_.Exception.Message -ForegroundColor Red exit 1 } Write-Host "按任意键退出..." $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")