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

I tried to run the "Enable-Migrations" command in a new project, and I received a 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 normally.

Why is this happening?

By the way, I am using VS2010 Professional SP1

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

+107
migration entity-framework
May 02 '12 at 10:00
source share
22 answers

I reinstalled using commmand: Install-Package EntityFramework -IncludePrerelease and the problem disappeared.

+75
May 7, '12 at 17:17
source share

Just for starters, Visual Studio worked for me. No need to install packages, etc.

+83
Feb 11 '15 at 23:17
source share

This problem occurs because we do not have the Entity Framework installed. Please install the Entity Framework using the command below.

 Install-Package EntityFramework -IncludePrerelease 

After installation, select a project from the default project drop-down list of the package manager console console.

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

 public class MyDbContext : DbContext { public MyDbContext() { } } 

If we do not, we get another error:

No context type was found in the assembly

After completing these things, you can run

 enable-migrations 
+20
May 20 '17 at 12:04
source share

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

+16
May 10 '15 at 6:01
source share

Launch Visual Studio as an administrator.

+13
Apr 16 '13 at 16:28
source share

First, “Install-Package EntityFramework -IncludePrerelease”, and then rebooting Visual Studio as an administrator worked for me together.

+9
Jul 17 '13 at 18:40
source share

I had the same issue with VS 2019 Preview, .Net Core and EntityFramework Core.

Turns out I had to install Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.Design through NuGet. Once this was done, it worked like a charm.

+4
Feb 19 '19 at 8:51
source share

In Visual Studio 2012, I had the same error. You have 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 the following windows: click the "Install" button, then click the "Close" button. Then close and reopen Visual Studio.

+3
Aug 13 '13 at 19:07 on
source share

What fixed this symptom for me (VS2013) was removing and then reinstalling the EF package using Nuget. The difference in the csproj file changed this ...

 <Reference Include="EntityFramework"> <HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath> </Reference> 

... in it...

 <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath> </Reference> 

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

+2
Dec 11 '14 at 3:59
source share

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

 Install-Package EntityFramework.Core -Pre 
+2
Jun 12 '16 at 14:18
source share

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

Steps:

 Install-Package EntityFramework -IncludePrerelease 

then create a class like

 public class MyDBContext : DbContext { public MyDBContext() { } } 

and last run

 Enable-Migrations -EnableAutomaticMigrations 

What didn't work for me:

: Restart VS.

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

: Restore or update the Nuget Package Manager.

My initial mistake at the beginning was

/ * The term "allow migration" is not recognized as the name of the cmdlet, function, script file, or running program. Check the spelling of the name or, if the path was specified, check the path and try again. In line: 1 character: 1 + enable -igration + ~~~~~~~~~~~~~~~~ CategoryInfo: ObjectNotFound: (enable-migration: String) [], CommandNotFoundException * /

+2
Aug 12 '18 at 1:26
source share

I had the same problem, and I found that this is due to some characters in the path to the project, for example [or] I am correcting the project path and it works great!

+1
Nov 27 '14 at 11:32
source share

Enable-Migrations -EnableAutomaticMigrations

+1
Oct 03 '16 at 5:42 on
source share

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

+1
Mar 28 '17 at 2:18
source share

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

+1
Dec 19 '17 at 17:59 on
source share
  1. Install the Entity framework into the current project using the following command: PM> Install-Package EntityFramework -IncludePrerelease

  2. Add the "MyDBContext" class to the "Model" folder, as shown below:

    public class MyDBContext: DbContext {public MyDBContext () {}}

  3. Now enable migrations for the current project with the following command: PM> enable-migrations

+1
Jul 29 '18 at 20:25
source share

In VS 2013, try installing UPDATE 1 (RC1) and the problem will be resolved.

0
Apr 26 '14 at 2:14
source share

I had several projects in solution, but I had the correct default set, so I thought it should work.

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

0
Feb 16 '16 at 15:05
source share

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

I noticed that packages/EntityFramework.6.1.3/tools/EntityFramework.psd1 missing, so that was the likely reason. How it was removed in the first place, although I have no idea.

0
Dec 12 '16 at 5:07
source share

Check if "entityFramework" configuration section exists in .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> 
0
Aug 21 '17 at 15:22
source share

run as administrator vs = >> open the opproject

 enabele-migration add-migration migrationName update-database 
0
May 7 '19 at 14:49
source share

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

This may be the cause of your problem.

-four
Sep 15 '16 at 0:51
source share



All Articles