Entity Framework won't install properly, Enable-Migrations command fails

entity-framework-6

Question

I am trying to follow this tutorial: https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/

I am using Visual Studio 2017 and Net 4.6.1.

Right off the bat, things seem to go wrong. When I use the command Install-Package EntityFramework in the Package Manager Console, I get this warning:

Missing function body in function declaration.

At C:\Users\TC\Documents\Temp\Entity Framework Example\MigrationsDemo\packages\EntityFramework.6.4.0\tools\EntityFramework6.PS2.psm1:241 char:5
+ <<<< WarnIfOtherEFs 'Enable-Migrations'
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingFunctionBody

Import-Module : The module to process 'EntityFramework6.PS2.psm1', listed in field 'ModuleToProcess' of module manifest 'C:\Users\TC\Documents\Temp\Entity Framework Example\MigrationsDemo\packages\EntityFramework.6.4.0\tools\EntityFramework6.PS2.psd1' was not processed because no valid module was found in any module directory.

At C:\Users\TC\Documents\Temp\Entity Framework Example\MigrationsDemo\packages\EntityFramework.6.4.0\tools\init.ps1:11 char:18
+ Import-Module <<<< (Join-Path $PSScriptRoot 'EntityFramework6.PS2.psd1')
+ CategoryInfo : ResourceUnavailable: (EntityFramework6.PS2:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

If I continue with the tutorial, everything works perfectly until I get to the step where I run Enable-Migrations in the Package Manager Console. That command fails with this error:

The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:18
+ Enable-Migrations <<<<
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Why am I getting this error, and what can I do to fix it?

Edit

I thought it might help to upgrade my development environment, so I switched to Visual Studio 2019 and targeted Net 4.7.2. I continue to get the exact same errors.

Can someone please tell me whether you can recreate the behavior I describe? It would be a big help to my debugging process to know whether the problem is on my end, or whether there is something wrong with EntityFramework which is causing the same errors for everyone.

Edit

Still trying to find a fix, I've been trying older versions of Entity Framework. The current version is 6.4.0 – doesn't work. The previous version is 6.3.0 – doesn't work. The version before that is 6.2.0 – works without a hitch. So, I'm going to start developing my project using 6.2.0. If anyone knows why the newer versions fail, please tell me. I'd like to be on the most recent version.

1
0
3/24/2020 11:21:01 PM

Popular Answer

I figured out what was wrong. Entity Framework 6.4.0 requires PowerShell 3 or higher. I was getting those errors because I had PowerShell 2. I fixed all my problems by upgrading PowerShell.

0
3/25/2020 5:40:23 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow