Introduction
This article explains how to install and uninstall Entity Framework in ASP.NET MVC Core. We can install and uninstall EF in two different ways, as explained below.
Installation
Step 1
Open Visual Studio 2017. Go to File >> New >> Project. Now, select “ASP.NET Core Web Application (.NET Core)” under the web in Visual C#. Selection looks like the below screenshot. Click OK.
Step 2
Now, the “New ASP.NET Core Web Application (.Net Core)” window will open. In this window, select ASP.NET Core version, select “Web Application”, and click OK.
Step 3
Our new project has opened. Go to Tools >> NuGet Package Manager, and click “Manage NuGet Packages for Solution”.
Now, the NuGet – Solution window will open. Select "Browse" in NuGet Solution and enter “entity framework core” in the search box. We get many lists after entering the keyword in the search box, the list looks like below screenshot. Locate “Microsoft.EntityFrameworkCore”.
If we are using SQL Server as a database, we can only install “Microsoft.EntityFrameworkCore.SqlServer”.
Step 4
Here, we are going to installing ”Microsoft.EntityFrameworkCore”. It is used to access the data for all different types of back-ends. Now, select “Microsoft.EntityFrameworkCore” and select cthe project check box that we are going to install. Then, click the Install button.
A preview window will open. Now, click OK button in the preview window.
Next, the License Acceptance window will open. For Entity Framework Core, we need to accept license terms so need to click “I Accept”.
Step 5
It will take few minutes to install EF core. We will be getting a success message after installation of EF Core, which looks like the below screenshot.
Step 6
Go to Solution Explorer >> Dependencies >> NuGet to locate the “Microsoft.EntityFrameworkCore” option.
Entity Framework Uninstall
We can uninstall Entity Framework from our project or our solution very easily. Go to Tools >> “NuGet Package Manager” >> “Manage NuGet Packages for Solution”.
Type “Microsoft.EntityFrameworkCore” in the search box and get lists. We see a green tick mark on items that are already installed in our solutions.
Now, select “Microsoft.EntityFrameworkCore” and the project checkbox will appear. We need to click on Uninstall button.
Again, a preview window will be opened. Now, click OK button from preview window which will uninstall the Entity Framework.
After uninstall, the “Microsoft.EntityFrameworkCore” file is removed from our project.
Conclusion
This article explained how to install and uninstall Entity Framework Core in ASP.NET MVC Core. I hope this is helpful to new learners.