How can I install and use Entity Framework Core in Visual Studio Code?

asp.net-core-mvc entity-framework-core visual-studio-code

Question

I have already created the initial asp.net mvc web application template in visual studio code. And I can run the application in a browser at localhost:5000/ I can also see the views, controllers, viewmodels like the previous asp.net mvc core.

Now, how can I install and use entity framework core using visual studio code?

Thanks.

1
11
6/4/2017 3:07:14 AM

Accepted Answer

VS Code is just an editor. It doesn't install EF (or any packages). You can install EF by editing your csproj file to contain this set of lines.

<ItemGroup>
   <PackageGroup Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
</ItemGroup>

VS Code may give you a prompt to "restore" pacakges. If not, call dotnet restore on command line.

Alternatively, on command line you can execute:

dotnet add package Microsoft.EntityFrameworkCore.SqlServer

See the "Getting Started" guide at http://docs.efproject.net/ for more details on EF. To use EF, you need to write code. A full example is beyond the scope of a good StackOverflow answer and is subject to change as EF Core continually updates.

15
6/4/2017 3:06:20 AM

Popular Answer

To be able to use entity framework in visual code you can use yeoman on the terminal:

>npm install -g yo
>npm install -g generator-efrepo
>yo efrepo

Then follow the instructions



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