install entity framework core in visual studio

in this video we will discuss how to install entity framework core in visual studio.

text version of the video
https://csharp-video-tutorials.blogspot.com/2019/04/install-entity-framework-core-in-visual.html

healthy diet is very important for both body and mind. we want to inspire you to cook and eat healthy. if you like aarvi kitchen recipes, please support by sharing, subscribing and liking.
https://www.youtube.com/channel/uc7sewixm_yfamyonqcrgfwa/?sub_confirmation=1

slides
https://csharp-video-tutorials.blogspot.com/2019/04/install-entity-framework-core-in-visual_22.html

asp.net core text articles & slides
https://csharp-video-tutorials.blogspot.com/2019/01/aspnet-core-tutorial-for-beginners.html

asp.net core tutorial
https://www.youtube.com/playlist?list=pl6n9fhu94yhvkdruslaqsferml_jh4xmu

angular, javascript, jquery, dot net & sql playlists
https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd

depending on how you have your project set up, you may have entity framework core already installed.

single layer web application

if it's a small project, you may have your presentation layer, business layer and data access layer all in one project. so if you have created a web application project using asp.net core 2.1 or higher, then in that web application project, you already have entity framework core installed.

entity framework core in asp.net core web application project

an asp.net core web application project that is created using asp.net core 2.1 or higher has the following nuget package installed.

microsoft.aspnetcore.app

this package is called - metapackage. a metapackage has no content of its own but is a list of dependencies (other packages). you can find this metapackage, in the solution explorer. when you expand the metapackage, you can find all the dependencies. in the dependencies you will find the entity framework core nuget packages already installed.

so the point that i am trying to make is, an asp.net core web application project that is created using asp.net core version 2.1 or later will have entity framework core already installed as part of the meta package.

multi layer web application

in a large application we will usually have at least the following 3 layers
presentation layer
business logic layer
data access layer

these layers are implemented as separate projects. entity framework core is usually required in the data access layer project. the data access layer project is a class library project and does not usually have the meta package referenced. so this means, entity framework core is not installed for the data access layer project.

to install entity framework core and to be able to use sql server as the database for your application, you need to install the following nuget packages.

microsoft.entityframeworkcore.sqlserver - this nuget package contains sql server specific functionality
microsoft.entityframeworkcore.relational - this nuget package contains functionality that is common to all relational databases
microsoft.entityframeworkcore - this nuget package contains common entity frameowrk core functionality

microsoft.entityframeworkcore.sqlserver has a dependency on microsoft.entityframeworkcore.relational package.
microsoft.entityframeworkcore.relational package has a dependency on microsoft.entityframeworkcore package.
microsoft.entityframeworkcore package has a dependency on several other packages.

when we install microsoft.entityframeworkcore.sqlserver package, it also installs all the other dependant nuget packages automatically.

in a class library project, to install a nuget package

right click on the "dependencies" node in "solution explorer" and select "manage nuget packages" from the context menu.

on the screen that pops up, search for the package that you want to install and follow the onscreen instructions.

we want to use sql server as the database for our application, so we used the nuget package microsoft.entityframeworkcore.sqlserver. this package is usually called database provider package.

if you want to use a different database with your application, then you will have to install that database provider specific nuget package instead of microsoft.entityframeworkcore.sqlserver database provider package.

for example, if you want to use mysql as your database, then install pomelo.entityframeworkcore.mysql database provider package. along the same lines, if you want to use postgresql as your database, use npgsql.entityframeworkcore.postgresql database provider package.

you can find all the provider specific nuget packages on the following msdn page
https://docs.microsoft.com/en-us/ef/core/providers/

install entity framework core in visual studio