Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"the term 'add-migration' is not recognized as the name of a cmdlet" visual studio 2019

enter image description here
enter image description here

I'm trying to use entity frame work core and have a fresh asp.net core project open. When i attempt to install Microsoft.EntityFrameworkCore.SqlServer through nuget package manager i get the following error.

Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0 is not compatible with net461 (.NETFramework,Version=v4.6.1). Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)

When i click this i get sent to .csproj file.

In that file i changed the target framework from <TargetFramework>net461</TargetFramework> to <TargetFramework>netstandard2.1 </TargetFramework> as the error implies.

Doing this gets rid of the error but when i use the command 'add-migration' in package manager console i get this error.

"The term 'add-migration' is not recognized as the name of a cmdlet"

I'm not sure what to do going forward. Please help. I hope i've explained the issue clearly.

Deleting the project.assets file or updating nuget package manger and using the the command "enable-migrations" hasnt worked either.

enter image description here
enter image description here

like image 409
Ahmed Bashir Avatar asked Dec 01 '22 13:12

Ahmed Bashir


2 Answers

The following helped me to add the missing tools to .net core 3.1

  1. Install-Package Microsoft.EntityFrameworkCore.Tools

  2. Update-Package Microsoft.EntityFrameworkCore.Tools

  3. Get-Help about_EntityFrameworkCore

From this Blog

like image 65
Tareq Avatar answered Dec 06 '22 08:12

Tareq


  1. Tools
  2. NuGet Package Manager
  3. Manage NuGet Package for Solution
  4. Install Microsoft.EntityFrameworkCore.Tools
  5. Try again
like image 31
John Pineda Avatar answered Dec 06 '22 06:12

John Pineda