Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(VS2017) There was an error running the selected code generator: 'Sequence contains no elements'

I'm running through one of Microsoft's tutorials on MVC development and I'm getting errors when trying to create various elements; Views, Controllers, etc.

The error I'm getting is the following:

There was an error running the selected code generator: 
'Sequence contains no elements'

It's consistant everytime I try to create a new element. Earlier, I bypassed the error by copying a view and repurposing it. But that's not optimal in the long run!

I'm currently sitting at work doing this tutorial where the issues arise. However, when I started this tutorial at home yesterday (hence, on a different network) I had zero issues. Might that have something to say?

Here's a link to the project on GitHub.

Do you think it's an issues with my network, my project itself, or something completely different?

like image 760
Patrick Christensen Avatar asked Jan 26 '18 09:01

Patrick Christensen


2 Answers

To anyone seeing this error when attempting to scaffold an upgraded .net6 project.

  • Scaffolds only work with the new style .net6 Minimal Hosting Model and I still had the .net5 style program and startup files.

This moved me next onto a frustrating EF Core issue 'unable to resolve service' error meaning Scaffold was unable to resolve the EF Contexts despite them being correctly in the new program.cs

  • Created a IDesignTimeDbContextFactory for Scaffold to detect the Context types.
like image 196
Huggster Avatar answered Oct 04 '22 03:10

Huggster


Visual Studio 2019 and .net core 3.0

Uninstalled: Microsoft.VisualStudio.Web.CodeGeneration.Design Version: 3.1.0-preview3.19558.8

and Installed: Microsoft.VisualStudio.Web.CodeGeneration.Design Version: 3.0.0

Solved the issue for me.

like image 27
Mohamed Elamin Avatar answered Oct 04 '22 02:10

Mohamed Elamin