Package Manager Console Enable-Migrations CommandNotFoundException only in a specific VS project

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Package Manager Console Enable-Migrations CommandNotFoundException only in a specific VS project



I tried to run the command 'Enable-Migrations' in a new project and I got the message:


PM> Enable-Migrations
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, verif
y that the path is correct and try again.
At line:1 char:18
+ Enable-Migrations <<<<
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException



But in all other projects the command runs just fine.



Why is this happening?



BTW, I'm using VS2010 Professional SP1



EDIT: I reinstalled with the commmand: Install-Package EntityFramework -IncludePrerelease
and the problem went away.





Hi, please add your solution as an answer and mark it as accepted (which you can do 2 days later), so it won't show up as unanswered question.
– Gert Arnold
May 2 '12 at 13:34





I'm having this exact same issue. But none of the things in this thread seems to work. Did you reinstall the entire visual studio or did you simply run that command?
– ObedMarsh
Feb 25 '14 at 19:06





I simply ran the command...
– Eduardo Brites
Feb 25 '14 at 20:51





Sadly, the results of that command for me are just "'EntityFramework 6.1.0' already installed." and it still doesn't have add-migration or enable-migrations as valid commands.
– Mir
Mar 19 '14 at 21:57





I am getting Install-Package : Unable to find package 'EntityFramework'. when i try your solution
– Naguib Ihab
Jul 28 '16 at 0:30




20 Answers
20



Just simply re-starting Visual Studio worked for me.
No need to install packages, etc.





re-starting VS also worked for me.
– A-Sharabiani
Aug 6 '15 at 15:36





Restarting VS also worked for me, glad I tried this before trying to reinstal the EntityFramework
– SM3RKY
Dec 10 '15 at 21:58





Restarting worked for Visual Studio 2015. No need to install packages.
– jonas
Jan 27 '16 at 13:36





A note - I have this issue every time I have to install my packages (like a fresh repo pull). Looks like VS needs to restart before the PM is initialized properly with the new packages (VS Community 2015 Update 1)
– Jono
May 5 '16 at 8:31





Fresh repo pull also caused this for me. Restart fixed it. (VS Enterprise 2015 Update 2).
– Mike Rouse
May 25 '16 at 19:17



I reinstalled with the commmand: Install-Package EntityFramework -IncludePrerelease and the problem went away.





I built my solution and then closed and reopened VS 2013 and it worked
– Luke
Sep 26 '14 at 20:43





Note that EntityFramework only supports .net framework 4.0 and 4.5. So, if you are using .net framework 4.6 or higher, it doesn't work.
– Tân Nguyễn
Jan 13 '17 at 13:46


EntityFramework





@TânNguyễn - what's that? my EntityFramework 6.1.3 NuGet is working fine in my 4.6.x project
– bkwdesign
May 30 '17 at 16:54






Restart didn't do it for me, but this did.
– robbpriestley
Sep 20 '17 at 22:11





This worked for me.. thanks
– Prasad Raja
Apr 24 at 6:27



Restarting Visual Studio with administrator privilege solved the issue for me.



This issue is occurring because we don't have Entity Framework installed.
Please install Entity Framework using the below command.


Install-Package EntityFramework -IncludePrerelease



Once installed, choose the project in the package manger console default project drop down.



Make sure at least one class in your project inherits from data context, otherwise use the below class:


public class MyDbContext : DbContext

public MyDbContext()





If we don't do this we will get another error:



No context type was found in the assembly


No context type was found in the assembly



After completing these things you can run


enable-migrations





Worked for me. Thanks.
– Najeeb
Nov 5 '17 at 17:42



Make you are running Visual Studio as a administrator.





I was running VS as administrator. At the time I didn't know we need to install the package on each project.
– Eduardo Brites
Apr 16 '13 at 16:35



First "Install-Package EntityFramework -IncludePrerelease" and then Restarting Visual Studio as a Administrator worked for me together.



In Visual Studio 2012 I had the same error. Had to uninstall NuGet (Tools > Extensions and Updates > Installed > All: NuGet Package Manager: Uninstall button). Then closed Visual Studio. Then reopened Visual Studio and reinstalled NuGet (Tools > Extensions and Updates > Online > Visual Studio Gallery: NuGet Package Manager: Download button). Then in following windows: click Install button, then click close button. Then close and reopen Visual Studio.





This worked for me, I think its a better option than forcing an upgrade to pre-release.
– OverMars
Feb 17 '14 at 22:48





That worked for me, thanks.
– Naguib Ihab
Jul 28 '16 at 0:40



In .NET Core, I was able to reach the same resolution as described in the accepted answer, by entering the following in package manager console:


Install-Package EntityFramework.Core -Pre



I had the same problem and I found that it is because of some characters in project path like [ or ]
I correct the project path and it worked fine!



What fixed this symptom for me (VS2013) is uninstalling then reinstalling the EF package with Nuget. The difference in the csproj file changed this...


<Reference Include="EntityFramework">
<HintPath>..packagesEntityFramework.6.1.1libnet45EntityFramework.dll</HintPath>
</Reference>



...into this...


<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..packagesEntityFramework.6.1.1libnet45EntityFramework.dll</HintPath>
</Reference>



I don't fully understand why yet, but it worked at least.





I had problems with add-migration/update-database etc. I tried all number of solutions but though I'm sure I already tried uninstalling and reinstalling EF, it didn't work. Until now when it did. This is not the first time I've had problems with EF packages. :(
– GeoffM
Feb 24 '15 at 2:56



Enable-Migrations -EnableAutomaticMigrations


Enable-Migrations -EnableAutomaticMigrations





i try it and it dons't work
– Osama khodrog
Oct 13 '16 at 9:59





After try several solutions, your solution works well for me.
– nguyenhoai890
Nov 23 '16 at 8:39





Worked for me on Visual Studio Community 2015. Thanks (All the other solutions failed on my case)
– fedeteka
May 14 at 19:40



Since I already had migrations folder, I restarted Visual Studio and ran
Update-Database -verbose
in package manager console. That worked for me



I tried all of the above suggestions but nothing worked for me then I updated Nuget Package Manager and it worked..


Nuget Package Manager



Install Entity framework to the current project using the below command:
PM> Install-Package EntityFramework -IncludePrerelease



Add a class "MyDBContext" in the Model folder as given below:



public class MyDBContext : DbContext

public MyDBContext()




Now enable migrations for the current project with the below command:
PM> enable-migrations



I had the same issue and I tried most of the solution provided by other folks but it worked for me with below steps. I have VS 2017.



Steps:


Install-Package EntityFramework -IncludePrerelease



then create a class as


public class MyDBContext : DbContext public MyDBContext()



and at the last execute


Enable-Migrations -EnableAutomaticMigrations



What didn't work for me:



: Restarting VS.



: only "Enable-Migrations" command, which is without -EnableAutomaticMigrations.



: restoring or updating Nuget Package Manager.



My original error in the beginning was



/*
The term 'enable-migration' 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:1
+ enable-migration
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (enable-migration:String) , CommandNotFoundException
*/



In VS 2013, try to install the UPDATE 1(RC1) and the problem is resolved.



I had multiple projects in the solution, but I had the correct Default Project set, so I thought it should work.



In the end, I had to add the -StartupProject MyProjectName option to the command


-StartupProject MyProjectName



None of these solutions worked for me. My solution was to delete packages/EntityFramework.6.1.3 and Restore NuGet Packages


packages/EntityFramework.6.1.3


Restore NuGet Packages



I noticed that packages/EntityFramework.6.1.3/tools/EntityFramework.psd1 was missing, so this was a likely cause. How it got removed in the first place though I have no clue.


packages/EntityFramework.6.1.3/tools/EntityFramework.psd1



Check if config section "entityFramework" exists and described in your .config file


<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/></configSections>

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>



Check if the project is open in the Solution Explorer window.



This could be the cause of your problem.





Don't find this correct..
– Ashish
Dec 23 '16 at 6:36






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS