다음을 통해 공유


Installation And Un-Installation Of Entity Framework Core In ASP.NET MVC Core

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.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image001.jpg

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.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image002.jpg

Step 3

Our new project has opened. Go to Tools >> NuGet Package Manager, and click “Manage NuGet Packages for Solution”.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image003.jpg

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”.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image004.jpg

If we are using SQL Server as a database, we can only install “Microsoft.EntityFrameworkCore.SqlServer”.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image005.jpg

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.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image006.jpg

A preview window will open. Now, click OK button in the preview window.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image007.jpg

Next, the License Acceptance window will open. For Entity Framework Core, we need to accept license terms so need to click “I Accept”.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image008.jpg

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.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image009.jpg

Step 6

Go to Solution Explorer >> Dependencies >> NuGet to locate the “Microsoft.EntityFrameworkCore” option.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image010.jpg

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”.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image011.jpg

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.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image012.jpg

Now, select “Microsoft.EntityFrameworkCore” and the project checkbox will appear. We need to click on Uninstall button.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image013.jpg

Again, a preview window will be opened. Now, click OK button from preview window which will uninstall the Entity Framework.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image014.jpg

After uninstall, the “Microsoft.EntityFrameworkCore” file is removed from our project.

http://csharpcorner.mindcrackerinc.netdna-cdn.com/article/installation-and-un-installation-ways-of-entity-framework-core-in-asp-net-mvc-co/Images/image015.jpg

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.