Entity Framework with NuGet - Import-Module error in init.ps1

放肆的年华 提交于 2019-12-20 07:28:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!