简体   繁体   中英

Error when adding a controller in Entity Framework

I was following Entity framework tutorial in Microsoft.

https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application#main

Here I've done up to Set up EF to use a SQL Server Express LocalDB database .And in Creating a Student Controller and Views section when I tried to add a controller using MVC 5 Controller with Views, using Entity Framework (as mentioned in the tutorial), I'm getting an error saying

Attempting to install version '6.1.1' of 'EntityFramework' but the project already includes a different version. Skipping...

I tried reinstalling Entity Framework using the console, but still, it doesn't solve the problem. Does anyone know how to solve it?

Try to uninstall Entity Framework an then reinstall it

Uninstall-Package EntityFramework -Force

Install-Package EntityFramework

Run this command in Package manager console:

Uninstall-Package EntityFramework -Force

then close visual studio and delete entity framework floder in packages.config

again open Visual Studio and run this command:

Install-Package EntityFramework

Recently run into the same error.

Resolved it by uninstalling all the ef core packages through Nuget package manager and re-installing them with the latest stable version (5.0.9)

I have re-installed following ef core packages

  • EntityFrameworkCore
  • EntityFrameworkCore.SqlServer
  • EntityFrameworkCore.Design
  • EntityFrameworkCore.Tools

Note: Don't forget to rebuild the solution

See below screenshot

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM