Skip to content

Commit

Permalink
Stop using AddFromFile with many files (#24937)
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Ejlskov Jensen <[email protected]>
  • Loading branch information
ErikEJ and Erik Ejlskov Jensen authored Jun 7, 2021
1 parent 061690f commit 40f3640
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/EFCore.Tools/tools/EntityFrameworkCore.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ function Add-Migration
$result = (EF $dteProject $dteStartupProject $params $Args) -join "`n" | ConvertFrom-Json
Write-Host 'To undo this action, use Remove-Migration.'

$dteProject.ProjectItems.AddFromFile($result.migrationFile) | Out-Null
$DTE.ItemOperations.OpenFile($result.migrationFile) | Out-Null
ShowConsole
if (!(IsCpsProject $dteProject) -or (GetCpsProperty $dteProject 'EnableDefaultItems') -ne 'true' -or (GetCpsProperty $dteProject 'EnableDefaultCompileItems') -ne 'true')
{
$dteProject.ProjectItems.AddFromFile($result.migrationFile) | Out-Null

$dteProject.ProjectItems.AddFromFile($result.metadataFile) | Out-Null
$dteProject.ProjectItems.AddFromFile($result.metadataFile) | Out-Null

$dteProject.ProjectItems.AddFromFile($result.snapshotFile) | Out-Null
}

$dteProject.ProjectItems.AddFromFile($result.snapshotFile) | Out-Null
$DTE.ItemOperations.OpenFile($result.migrationFile) | Out-Null
ShowConsole
}

#
Expand Down Expand Up @@ -595,8 +599,12 @@ function Scaffold-DbContext
# NB: -join is here to support ConvertFrom-Json on PowerShell 3.0
$result = (EF $dteProject $dteStartupProject $params $Args) -join "`n" | ConvertFrom-Json

$files = $result.entityTypeFiles + $result.contextFile
$files | %{ $dteProject.ProjectItems.AddFromFile($_) | Out-Null }
if (!(IsCpsProject $dteProject) -or (GetCpsProperty $dteProject 'EnableDefaultItems') -ne 'true' -or (GetCpsProperty $dteProject 'EnableDefaultCompileItems') -ne 'true')
{
$files = $result.entityTypeFiles + $result.contextFile
$files | %{ $dteProject.ProjectItems.AddFromFile($_) | Out-Null }
}

$DTE.ItemOperations.OpenFile($result.contextFile) | Out-Null
ShowConsole
}
Expand Down

0 comments on commit 40f3640

Please sign in to comment.