I\'m using Visual Studio 2019 version 16.0.4, and I tried to create a view or a partial one on asp.net core 2.1 (in views folder) but I get an error
I was mistaken (24th Update), see comments on this post, it's apparently still broken, either way, the original answer below still works, in both cases.
The answer below still stands if your using an older release of Visual Studio 2019, however please be aware this has now been fixed in the more up-to date releases:
https://developercommunity.visualstudio.com/content/problem/562039/there-are-no-scaffolders-supported-for-this-item-1.html
Original Answer
There's currently a known bug in Visual Studio 2019 for this scenario.
There is some semi official advice on the GitHub issue tracker, but it doesn't always work.
MS Will fix it eventually, there appears to currently be no timescale.
For now however, if you right click and use add new item:
Then pick the item type you want (In my case it's a razor page)
Then you'll find everything still works as expected. The bug only seems to affect the shortcut menus.
I Created a folder named Views and Error never shows again
I solved it by downgrade Microsoft.VisualStudio.Web.CodeGeneration.Design on version 2.2.4 from 3.x. from Nuget packages for my solution. I hope it helps some one.
None of the above fixed my issue, so I thought I'd leave feedback as well. Updating .NET versions fixes this for me. I was on 4.5 and moved up to 4.5.2. To test this, I created a sibling project of the same type (.NET MVC Web) with 4.5.2, and tried to create scaffolding items again, and it works.
I will either use the new project to house my scaffolding items, or try to upgrade my original project to 4.5.2. I'm sure any version over 4.5.2 would work as well, but I'm using an older one due to server architecture.
UPDATE: It would appear that updating the version is not what solved the issue. So it was the act of adding a new project that works... I'm not sure why though. I will update this again if I find out.
I see this problem in my visual studio when I add "Pages" Folder to my ASP.NET MVC core project. before I adding this folder, scaffolding works fine, and when I add this, I see the error. Also when I remove "Pages" folder, scaffolding work fine again. ;)
I don't know if it is my same problem but its very similar...
My solution was update NuGet.Frameworks
*My problem:
For example, I created a method called AnyName, next I did double click and add new View
Image1
So, next I simply did click in add new Razor View Image2
Next start the Scaffolding to create the new View: Image3
But it cant create the view and send the follow error: there was an error running the selected code generator package restore failed (there was an error running the selected code generator package restore failed)
Im Using: VSCommunity 2019 v16.7.2*