From 9d76d852adb2779f9bbd12ab8db2fcb219b43315 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 | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 index 5da4c5e8324..27e3b8cf7c1 100644 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 @@ -147,10 +147,10 @@ Register-TabExpansion Get-DbContext @{ <# .SYNOPSIS - Gets information about a DbContext type. + Gets information about DbContext types. .DESCRIPTION - Gets information about a DbContext type. + Gets information about DbContext types. .PARAMETER Context The DbContext to use. @@ -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 + } } #