60827

Entity Framework Import-Module : The specified module '…EntityFramework.psd1' was not load

Question:

Recently I decided to use Entity Framework for a personal project. From my Visual Studio 2013 community edition and using NuGet I installed the latest version of the framework (nuget version 2.8.60318.734 and Entity Framework 6.1.3)

Everything seems to work OK I was able to perform simple CRUD operations, till I needed to update my model. After it, of course I got the error message:

“Additional information: The model backing the 'MyContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).”

Seems an appropriate error message, I just need to Enable-Migrations. Switch to Package Manager Console and there was a message in bright red background

PM> Import-Module : The specified module 'D:\[MyProjects]\[ProfOfConcept]\EntityFrameworkInvalidFilepath\packages\EntityFramework.6.1.3\tools\EntityFramework.psd1' was not loaded because no valid module file was found in any module directory. At D:\[MyProjects]\[ProfOfConcept]\EntityFrameworkInvalidFilepath\packages\EntityFramework.6.1.3\tools\init.ps1:8 char:14 + Import-Module <<<< (Join-Path $toolsPath EntityFramework.psd1) + CategoryInfo : ResourceUnavailable: (D:\[MyProjects]...yFramework.psd1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Hmmmm something is wrong, I guess some needed part of the framework was not correctly installed, but let's check the file. The file was present, and the content seemed OK.

Alright let's try to reinstall it, just in case something went wrong at the first time. Using NuGet I tried to uninstall, and reinstall.

Checking Package Manager Console, again the same dreaded error!

Hmmm, let's try to do the uninstall /reinstall from the Package Manager Console. Again the same error!

After spending more time trying to Google similar problems I came across someone describing a similar problem <a href="https://stackoverflow.com/questions/9903303/entity-framework-with-nuget-import-module-error-in-init-ps1" rel="nofollow">Entity Framework with NuGet - Import-Module error in init.ps1</a> Tried that… no luck.

So what is really going on? In a Eureka moment I thought… hold on, what was my project path?

D:\[MyProjects]\[ProofOfConcept]\….

Could it be? Could the square brackets be the reason?

Create a copy the project to a simple path (d:\tmp\myProject) start the Visual Studio, enter Package Management Console, …. no error !

Enable-Migrations PM> Enable-Migrations Checking if the context targets an existing database... Detected database created with a database initializer. Scaffolded migration '201504051040353_InitialCreate' corresponding to existing database. To use an automatic migration instead, delete the Migrations folder and re-run Enable-Migrations specifying the -EnableAutomaticMigrations parameter. Code First Migrations enabled for project EntityFrameworkInvalidFilepath.

That's it!! The square brackets are the culprits

So the bottom line is this, if you are using Entity Framework <strong>don’t use [ ]</strong> in the path.

Answer1:

I recently had the same issue with NuGet not installing EF 6.1.3 properly because the EntityFramework.psd1 file wasn't being imported. Uninstalling and re-installing EF through Visual Studio didn't help.

What worked for me was to quit VS, navigate to '[Project Root Directory]\packages' and delete the EntityFramework6.1.3 directory. When you restart VS and go to the package manager console, it will let you know that there are modules missing and ask if you want to import them. When you click 'Reload' EF 6.1.3 is installed properly under the 'packages' directory.

In my case I'm using the 2015RC, which has <a href="https://github.com/aspnet/EntityFramework/issues/1950" rel="nofollow">a lot of issues with EF migrations</a>.

Recommend

  • VS2010 LoadFrame fails with error 1401in release mode
  • Spring JDBC : unable to get dataSource
  • How to update TortoiseSVN over the network?
  • powershell: run code when importing module
  • Unit testing method converting MVC view to string using View.Render method
  • Install Neo4j 3.0+ as a windows service
  • Can I customize a Jackson ObjectMapper by adding a module?
  • Guice, Injecting TypeLiteral when using @AssistedInject
  • Kinect API written solely in Java without native functions?
  • How to make http call with file in groovy to upload a file and build arguments
  • Jackson Java 8 DateTime serialisation
  • Importing pyplot in a Jupyter Notebook
  • What's an elegant way of accessing parent controller's member from child controller?
  • Ruby regex to remove all consecutive letters from string
  • No such module 'Parse' following Parse iOS Swift Quickstart guide
  • How to set a thread specific environment variable in Python?
  • Error while importing scikits.talkbox
  • Accessing 3rd level of JSON with Angular ng-repeat
  • Error “Reflect.defineMetadata” while trying to load a transient web worker
  • How to generate an asynchronous reset verilog always blocks with chisel
  • replacing while loop with list comprehension
  • Calling C function from lua
  • How to add javascript in a prestashop module
  • Can't resolve 'jquery' with typescript
  • Using SWIG with a build system [closed]
  • Print character to a certain point on console in Python?
  • How do you keep a running instance for Google App Engine
  • py4j.protocol.Py4JJavaError when selecting nested column in dataframe using select statetment
  • Python 3.2.2, error(scripts to exe)
  • python mysqldb delete row
  • import scipy.sparse failed
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • Autofac with Web API 2 - Parameter-less constructor error
  • pillow imaging ImportError
  • Authentication in Play! and RestEasy
  • Django simple Captcha “No module named fields” error
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Is there a perl module to validate passwords stored in “{crypt}hashedpassword” “{ssha}hashedpassword
  • Meteor helpers not available in Angular template
  • using HTMLImports.whenReady not working in chrome