0

I am very new to EntityFramework development, not to mention to .NetCore and MVC design pattern, I actually started with .NetCore development with a introduction book to those subjects, I reached a chapter where the autor starts with an MVC project (still using .NetCore 2.0) and do Scaffolding to create the EF model based on a Database previously created, then he jumps to add a controller via wizard, chosing the option that says: "MVC Controller with views, using Entity Framework", but when I do this, a get the 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 adding this files manually and detected that this happens when I try (or the wizard tries) to create the view file, either using an empty template or using one of the models, the result is the same. I thought it was for the NuGet packages that where "asking" for updates, so I updated them, but nothing changed, I recreated the project several times, trying to leave the NuGet packages versions that the autor mentions to install, and to have "everything up to date" but still got the same.

I found another question in here with the same problem, and tried the possible solutions that mentions there, but none worked for me, I even try to install the versions 2.0.0 (or the lowest if there where no version 2.0.0) of the NuGet packages needed (or rather, mentioned by the author), and there was a change, still an error, but a different one, that says that the Microsoft.AspNetCore.Razor.Design.targets file needs a value on Configuration...?, still not know what to do, I noticed that updating 3 packages eliminates this error but is going back to the views error.

I don't know what else can I do or how to address this problem.

4
  • You need the Microsoft.VisualStudio.Web.CodeGeneration.Design NuGet installed. Make sure you have that, if you don't already. Then try doing a dotnet restore directly from the command line. Also, ensure that your solution builds successfully. If any projects are failing their builds, that will affect the scaffolding from working successfully. Commented Jul 15, 2019 at 19:58
  • I just did the dotnet restore and got the same error, the project builds correctly and that package is installed, is one of the package the autor mentions to install after creating the project. Commented Jul 15, 2019 at 20:23
  • What is your EF Core version?Do you have problem when you create a new asp.net core 2.0 project? Commented Jul 16, 2019 at 7:48
  • @XingZou the EF Core version is 2.0.0, I have no problems creating projects with asp.net core 2.0, at least none have appeared the times I re-created the same project of the book that I'm following Commented Jul 16, 2019 at 14:49

1 Answer 1

1

I finally made it work, although at the end, I don't know what was the problem, what I did was to uninstall all the NuGet packages, then reinstall one by one, chosing the 2.0.0 versions of each one (or the lowest if there was no 2.0.0 version) until there where no sintax errors (by the way, I already had done this, but I don't know what changed) and ended up with 13 packages installed, after verifying that the project builds correctly, I tried again to add via wizard the controller and the view and it threw another error asking to update just two packages (EntityFrameworkcore and EntityFrameworkCore.Design) to versions 2.0.3, after that, I was able to add both the controller and the views with no problem at all and the project still builds correctly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.