问题
Here is the complete error message that I get in the Package Manager Console when starting VS2010:
Import-Module : The specified module 'C:\Users\adam.assman\Project\packages\EntityFramework.4.3.1\tools\EntityFramework.psd1' was not loaded because no valid module file was found in any module directory. At C:\Users\adam.assman\Project\packages\EntityFramework.4.3.1\tools\init.ps1:13 char:14
I've installed Entity Framework using NuGet, on a DLL/ClassLibrary project in my solution. The startup project is referencing and using this DLL project. I therefore tried running the startup command from the console with the DLL project selected in the dropdown "Default Project", but that gives me the same error message.
I have NuGet version 1.6.21215.9133 (and obviously EF version 4.3.1).
If I try to run the command "Enable-Migrations -EnableAutomaticMigrations", I get a CommandNotFoundException
and I suppose it's a result from the init error. I'm trying to accomplish the simplest form of the automatic migrations, using this guide: http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-automatic-migrations-walkthrough.aspx
回答1:
I have no idea what was wrong, but I finally fixed this by editing the file init.ps1
inside the folder \packages\EntityFramework.4.3.1\tools
.
I changed this line:
Import-Module (Join-Path $toolsPath 'EntityFramework.psd1') -ArgumentList $installPath
Into this:
Import-Module '.\packages\EntityFramework.4.3.1\tools\EntityFramework.psd1' -ArgumentList $installPath
来源:https://stackoverflow.com/questions/9903303/entity-framework-with-nuget-import-module-error-in-init-ps1