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

前端 未结 13 2267
忘了有多久
忘了有多久 2021-01-04 11:34

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 e

相关标签:
13条回答
  • 2021-01-04 11:44

    This worked for me for VS 2017.

    Close the opened instance of VS 2017. Open it again. Rebuild the solution and now create View, Controller etc. It will be created now.

    0 讨论(0)
  • 2021-01-04 11:50

    you must update or install the version of Microsoft.VisualStudio.Web.CodeGeneration.Design package .

    this is the solution, respects .

    0 讨论(0)
  • 2021-01-04 11:51

    All the answers above didn't work for me.

    However, this is the Error message i got -
    "detected package version outside of dependency constraint microsoft.aspnetcore.app 2.1.1 requires microsoft.netcore.razor.design...bla bla bla"

    How i overcame it was to install a lower version of razor via nuget package manager:

    Steps:

    on Visual Studio 2017 Click on Tools > Nuget Package Manager > Package Manager Console then run the command below.

    Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 2.1.1

    0 讨论(0)
  • 2021-01-04 11:53

    Try clearing the ComponentModelCache, the cache will rebuild next time VS is launched.

    1. Close Visual Studio Delete everything in this folder
    2. C:\Users\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
    3. Restart Visual Studio 14.0 is for visual studio 2015. This will work for other versions also.

    Credit to https://stackoverflow.com/a/35815094/5209435

    Edit

    Are your providerNames in the connectionString section of your web.config file the same?

    You may also want to try the suggested solutions from here or here.

    0 讨论(0)
  • 2021-01-04 11:56

    Turns out for me that Microsoft.VisualStudio.Web.CodeGeneration.Design was restored using the wrong .NetFramework version. So I launched the package manager console (Tools > NuGet Package Manager > Package Manager Console) and typed Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 3.0.0

    This fixed it for me.

    0 讨论(0)
  • 2021-01-04 11:57

    I have no evidence of the root cause, but the following issue wastes my two days ago to find out the solution.

    If there big data table type in your model class, check the following word has existed

    [Column(TypeName = "ubigint")]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    

    in your model class. Just take out these two-line, everything is going to be fine.

    0 讨论(0)
提交回复
热议问题