From 041f501b13ddbf11b1d451f6b5a5ee1b9a274c7c Mon Sep 17 00:00:00 2001 From: ErikEJ Date: Wed, 8 May 2019 08:03:33 +0200 Subject: [PATCH] Modify Get-DbContext command to list DbContexts fixes #15104 --- .../tools/EntityFrameworkCore.psm1 | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 index 5da4c5e8324..5a1abe30139 100644 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 @@ -147,7 +147,7 @@ Register-TabExpansion Get-DbContext @{ <# .SYNOPSIS - Gets information about a DbContext type. + Gets information about DbContext types. .DESCRIPTION Gets information about a DbContext type. @@ -172,11 +172,19 @@ function Get-DbContext $dteProject = GetProject $Project $dteStartupProject = GetStartupProject $StartupProject $dteProject - $params = 'dbcontext', 'info', '--json' - $params += GetParams $Context - - # NB: -join is here to support ConvertFrom-Json on PowerShell 3.0 - return (EF $dteProject $dteStartupProject $params) -join "`n" | ConvertFrom-Json + if ($Context) + { + $params = 'dbcontext', 'info', '--json' + $params += GetParams $Context + # NB: -join is here to support ConvertFrom-Json on PowerShell 3.0 + return (EF $dteProject $dteStartupProject $params) -join "`n" | ConvertFrom-Json + } + else + { + $params = 'dbcontext', 'list', '--json' + # NB: -join is here to support ConvertFrom-Json on PowerShell 3.0 + return (EF $dteProject $dteStartupProject $params) -join "`n" | ConvertFrom-Json | Format-Table -Property safeName -HideTableHeaders + } } #