How to Install Entity Framework Core in ASP.NET Core

Today, You will learn How to install Entity Framework Core in the ASP.NET Core Web application. Entity Framework Core is a Nugget package that can be added to your application/project in a number of ways depending upon your IDE and project type.

What is Entity Framework Core?

Entity Framework Core is an ORM (Object-Relational Mapper) software that is lightweight, extensible, and open-source. Entity Framework Core is cross-platform like .NET Core and supports windows, Linux, and Mac OS.

What is ORM?

ORMis Object-Relational mapper that allows developers to connect with databases through business objects. So developers perform operations on business objects and ORM translates the action to SQL scripts to manipulate the database.

What is Entity Framework Core Code first approach?

There are two approaches that are used in Entity Framework Core.

  • Code first approach
  • Database first approach

Mostly “code first approach” is used because there is limited support for the “database first approach” by Entity Framework Core.

Entity Framework Core doesn’t belong to the .NET Core of .NET. It’s a nugget package that can be added to your project simply according to your tools and project type.

In this tutorial, I will discuss how you can install Entity Framework Core into your .NET 5 application using visual studio community 2019.

Let’s get started:

In the Solution Explorer right-click on “Dependencies” and select “Manage NuGet Packages”.

Install Entity Framework Core

Search for “Microsoft.EntityFrameworkCore.SqlServer” and check the author it must be Microsoft.

Microsoft.EntityFrameworkCore.SqlServer

Install the package and you will get a pop-up like this for the license agreement. Make sure to select the right version for project Entity Framework Core version 6 supports .NET 6. If you are using .NET 5 or the previous version select accordingly. I’m using .NET 5, so I selected version 5.0.12 for Entity Framework Core.

License acceptance

After acceptance of this agreement, our package will be installed.

Now you can find the package in solution explorer under dependencies.

solution explorer

There is a second way that you can use to install Entity Framework Core through Package Manager Console. Go to Tools -> NuGet Package Manager -> Package Manager Console and execute the following command to install the SQL Server provider package.

PM> Install-Package Microsoft.EntityFrameworkCore.SqlServer

Conclusion:

Try this tutorial and if you do not understand anything or face any issue while applying this method. Do not hesitate to comment below. MYCODEBIT team will try to respond ASAP.

Leave a Reply

Your email address will not be published.