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 recog
Since I already had migrations folder, I restarted Visual Studio and ran Update-Database -verbose in package manager console. That worked for me
Just simply re-starting Visual Studio worked for me. No need to install packages, etc.
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>
if you create an MVC Web project You should select Authentication when creating the project . by defaults is not selected.
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
After completing these things you can run
enable-migrations
run as administrator vs =>> Open the project
-> On the Package manager Console
Enable-migration
add-migration migrationName
update-database