Search code examples
entity-framework-corecode-generation.net-6.0visual-studio-2022

There was an error running the selected code generator: 'Scaffolding failed. The path is empty. (Parameter 'path')' in VS 2022


Project type is asp.net MVC core. Adding a Razor View with or without Model I receive the following results:

There was an error running the selected code generator: 'Scaffolding failed. The path is empty. (Parameter 'path')'

Using VS2022 17.0.4 targeting .net 6.0 EntityFrameworkCore 6.0.1

I tried some of the remedies from the question that pops up on SO for VS2013:

  1. cleaned out bin and obj folders and rebuilt
  2. verified that all projects with EntityFrameWorkCore had the same version

BTW, adding a controller works.

Any help or guidance would be welcomed. This is a show stopper.

EDIT: I noticed that some or all of the projects in the solution were corrupted so I recreated project from scratch. I was able to add two views and then I received the message as above, again. Also, as I was building the project again I tested by adding a Razor view before I made any changes to the template generated project (asp.net core MVC) and it worked.

Something is corrupting one or more of my projects, and I think it might be NuGet. Any help would be greatly appreciated. I will now go rebuild the project from scratch for a third time and observe better and more frequently as to when the add Razor view fails.


Solution

  • When I was recreating the solution from scratch I found the culprit. ME!

    I do not like the new style of Main entry points where the code just starts without a namespace or class definition such as follows:

    namespace MyNamespace
    {
        public static class MyClass
        {
            public static void Main(string[] args)
            {
            }
        }
    }
    

    So I rewrote the class Program and created Startup and attempted to refactor all the code from Program. Obviously I did not do well. This caused my problem with the failed add of a templated Razor view.