Skip to content

Commit e174319

Browse files
ErikEJajcvickers
authored andcommitted
Modify Get-DbContext command to list DbContexts
fixes #15104
1 parent 7343fa1 commit e174319

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/EFCore.Tools/tools/EntityFrameworkCore.psm1

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ Register-TabExpansion Get-DbContext @{
147147

148148
<#
149149
.SYNOPSIS
150-
Gets information about a DbContext type.
150+
Gets information about DbContext types.
151151
152152
.DESCRIPTION
153-
Gets information about a DbContext type.
153+
Gets information about DbContext types.
154154
155155
.PARAMETER Context
156156
The DbContext to use.
@@ -172,11 +172,19 @@ function Get-DbContext
172172
$dteProject = GetProject $Project
173173
$dteStartupProject = GetStartupProject $StartupProject $dteProject
174174

175-
$params = 'dbcontext', 'info', '--json'
176-
$params += GetParams $Context
177-
178-
# NB: -join is here to support ConvertFrom-Json on PowerShell 3.0
179-
return (EF $dteProject $dteStartupProject $params) -join "`n" | ConvertFrom-Json
175+
if ($Context)
176+
{
177+
$params = 'dbcontext', 'info', '--json'
178+
$params += GetParams $Context
179+
# NB: -join is here to support ConvertFrom-Json on PowerShell 3.0
180+
return (EF $dteProject $dteStartupProject $params) -join "`n" | ConvertFrom-Json
181+
}
182+
else
183+
{
184+
$params = 'dbcontext', 'list', '--json'
185+
# NB: -join is here to support ConvertFrom-Json on PowerShell 3.0
186+
return (EF $dteProject $dteStartupProject $params) -join "`n" | ConvertFrom-Json | Format-Table -Property safeName -HideTableHeaders
187+
}
180188
}
181189

182190
#

0 commit comments

Comments
 (0)