Search code examples
entity-frameworkasp.net-core-2.0scaffolding

How to fix 'Failed to Update dependency information of the project. Please restore the project and try again'


I'm writing a new web API using .net core 2.2 and I connected an existing database using entity framework. but I keep getting an error saying above when I try to add a controller to the existing model using Scaffold new item. here are the commands I used

Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

Scaffold-DbContext to reverse engineer and create the EF model based on my existing database.

but keeps getting below error

"There was an error running the selected code generator: ' Failed to update dependency information for the project. Please restore the project and try again.'

I tried everything I could think of and I even gets the same error when I tries to add an empty controller also


Solution

  • It was due to a mismatch between .netCore version and EntityFrameworkCore version.

    Edit I uninstalled the EFCore and installed a parallel versiion for .net core

    Ex .netCore 2.0.9 EFCore 2.2.4