Visual Studio Code Entity Framework Core Add-Migration not recognized

c# entity-framework-core visual-studio-code

Question

I've used yoman to generate an ASP.Net Core Web API application via the Visual Studio Code Editor. For reference, I followed this tutorial here

The API works fine. However, I am trying to use Entity Framework Core Migrations with SQL Server. When I type the following into the Visual Studio Code Terminal:

Add-Migration MyDbInitialMigration

I get the following message:

'Add-Migration' is not recognized as an internal or external command, operable program or batch file.

I have the Microsoft.EntityFrameworkCore.Tools: 1.1.0-preview4-final dependency installed. I did this using the .Net Core Project Manager (Nuget) extension.

In Visual Studio 2015 this command works fine from the Package Manager Console.

I assume that using Visual Studio Code's Terminal is the problem. But does anyone know how I can use EF Core Migrations from within the VS Code editor itself?

Thanks for any help.

Solution

Running the dotnet ef migrations add InitialCreate command yielded the following error:

No executable found matching command "dotnet-ef"

To solve this I needed to install the following dependency, AND add it to the tools section:

Microsoft.EntityFrameworkCore.Tools.DotNet
1
19
1/8/2017 7:36:52 PM

Accepted Answer

The correct format to add a new migration is dotnet ef migrations add yourMigrationName

and to update database is dotnet ef database update

36
1/23/2018 3:35:38 PM

Popular Answer

Step 1 First we need to add reference in *.csproj file in the following way

Step 2 in Bash/Command propt

dotnet restore

Step 3

dotnet ef migrations add MyDbInitialMigration



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow