0
votes

I have installed Entity Framework thorough nuget. I have VS2019 .net console application.

In the Package Manager console, I run Enable-Migrations.

I get exception:

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, verify that the path is correct and try again.

At line:1 char:18
+ Enable-Migrations <<<<
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

1
Unless you're developing against something predating .Net Core (EF 6 and lower), you don't need to do enable-migrations. Just run add-migration InitialCreate -c MyDbContext - Dennis1679
Entity Framework (.Net, EF 6 and lower) has different NuGet commands than Entity Framework Core. I suspect you probably either a) installed the wrong version of EF, or b) you have the right version, but the wrong NuGet commands. QUESTION: Is your .project .Net, or .Net Core? - FoggyDay
My project is .Net. I installed: <package id="EntityFramework" version="6.4.0" targetFramework="net472" /> I run add-migration InitialCreate -c DealerContext . I still get The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of th e name, or if a path was included, verify that the path is correct try again. + add-migration <<<< InitialCreate -c DealerContext + CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException - jivangilad

1 Answers

0
votes

I am currently using Visual Studio 2019 and this worked for me.

  1. You need to install first Entity Framework

    Install-Package EntityFramework -IncludePrerelease
    
  2. Then try to make sure that one of your classes inherits data context

  3. Try running enable-migrations again.