-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add more contextual error messages to EF commands #5479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| @{ | ||
| # Script module or binary module file associated with this manifest | ||
| ModuleToProcess = 'EntityFrameworkCore.PowerShell2.psm1' | ||
|
|
||
| # Version number of this module. | ||
| ModuleVersion = '1.0.0' | ||
|
|
||
| # ID used to uniquely identify this module | ||
| GUID = '2de7c7fd-c848-41d7-8634-37fed4d3bb36' | ||
|
|
||
| # Author of this module | ||
| Author = 'Entity Framework Team' | ||
|
|
||
| # Company or vendor of this module | ||
| CompanyName = 'Microsoft Corporation' | ||
|
|
||
| # Copyright statement for this module | ||
| Copyright = '(c) .NET Foundation. All rights reserved.' | ||
|
|
||
| # Description of the functionality provided by this module | ||
| Description = 'Entity Framework PowerShell module used for the Package Manager Console' | ||
|
|
||
| # Minimum version of the Windows PowerShell engine required by this module | ||
| PowerShellVersion = '1.0' | ||
|
|
||
| # Name of the Windows PowerShell host required by this module | ||
| PowerShellHostName = 'Package Manager Host' | ||
|
|
||
| # Minimum version of the Windows PowerShell host required by this module | ||
| PowerShellHostVersion = '1.2' | ||
|
|
||
| # Minimum version of the .NET Framework required by this module | ||
| DotNetFrameworkVersion = '4.0' | ||
|
|
||
| # Minimum version of the common language runtime (CLR) required by this module | ||
| CLRVersion = '' | ||
|
|
||
| # Processor architecture (None, X86, Amd64, IA64) required by this module | ||
| ProcessorArchitecture = '' | ||
|
|
||
| # Modules that must be imported into the global environment prior to importing this module | ||
| RequiredModules = 'NuGet' | ||
|
|
||
| # Assemblies that must be loaded prior to importing this module | ||
| RequiredAssemblies = @() | ||
|
|
||
| # Script files (.ps1) that are run in the caller's environment prior to importing this module | ||
| ScriptsToProcess = @() | ||
|
|
||
| # Type files (.ps1xml) to be loaded when importing this module | ||
| TypesToProcess = @() | ||
|
|
||
| # Format files (.ps1xml) to be loaded when importing this module | ||
| FormatsToProcess = @() | ||
|
|
||
| # Modules to import as nested modules of the module specified in ModuleToProcess | ||
| NestedModules = @() | ||
|
|
||
| # Functions to export from this module | ||
| FunctionsToExport = ( | ||
| 'Add-Migration', | ||
| 'Enable-Migrations', | ||
| 'Remove-Migration', | ||
| 'Scaffold-DbContext', | ||
| 'Script-Migration', | ||
| 'Update-Database', | ||
| 'Use-DbContext' | ||
| ) | ||
|
|
||
| # Cmdlets to export from this module | ||
| CmdletsToExport = @() | ||
|
|
||
| # Variables to export from this module | ||
| VariablesToExport = @() | ||
|
|
||
| # Aliases to export from this module | ||
| AliasesToExport = @() | ||
|
|
||
| # List of all modules packaged with this module | ||
| ModuleList = @() | ||
|
|
||
| # List of all files packaged with this module | ||
| FileList = @() | ||
|
|
||
| # Private data to pass to the module specified in ModuleToProcess | ||
| PrivateData = '' | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| $versionErrorMessage = "EF commands do not support PowerShell version $($PSVersionTable.PSVersion). Please upgrade PowerShell to 3.0 or greater and restart Visual Studio." | ||
|
|
||
| function Add-Migration { | ||
| throw $versionErrorMessage | ||
| } | ||
|
|
||
| function Enable-Migrations { | ||
| throw $versionErrorMessage | ||
| } | ||
|
|
||
| function Remove-Migration { | ||
| throw $versionErrorMessage | ||
| } | ||
|
|
||
| function Scaffold-DbContext { | ||
| throw $versionErrorMessage | ||
| } | ||
|
|
||
| function Script-Migration { | ||
| throw $versionErrorMessage | ||
| } | ||
|
|
||
| function Update-Database { | ||
| throw $versionErrorMessage | ||
| } | ||
|
|
||
| function Use-DbContext { | ||
| throw $versionErrorMessage | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,20 @@ | ||
| param ($installPath, $toolsPath, $package, $project) | ||
|
|
||
| if (Get-Module | ? Name -eq EntityFrameworkCore) { | ||
| Remove-Module EntityFrameworkCore | ||
| if ($PSVersionTable.PSVersion.Major -lt 3) { | ||
| # This section needs to support PS 2.0 syntax | ||
| # Use $toolsPath because PS 2 does not support $PSScriptRoot | ||
| $env:PSModulePath= $env:PSModulePath + ";$toolsPath" | ||
|
|
||
| # import a "dummy" module that contains matching functions that throw on PS2 | ||
| Import-Module ([System.IO.Path]::Combine($toolsPath, "EntityFrameworkCore.PowerShell2.psd1")) -DisableNameChecking | ||
|
|
||
| throw "EF commands do not support PowerShell version $($PSVersionTable.PSVersion). Please upgrade PowerShell to 3.0 or greater and restart Visual Studio." | ||
| } else { | ||
|
|
||
| if (Get-Module | ? Name -eq EntityFrameworkCore) { | ||
| Remove-Module EntityFrameworkCore | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a shame PowerShell doesn't just do this using the package metadata. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PowerShell will actually throw an error on PS 2.0 because of syntax errors...but yeah, PS2 ignores metadata in psd1 |
||
| Import-Module (Join-Path $PSScriptRoot EntityFrameworkCore.psd1) -DisableNameChecking | ||
| } | ||
|
|
||
| Import-Module (Join-Path $PSScriptRoot EntityFrameworkCore.psd1) -DisableNameChecking | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does we require Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.NET Core CLI doesn't launch exes on non-Windows. This would require mono.