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
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.
you must update or install the version of Microsoft.VisualStudio.Web.CodeGeneration.Design package .
this is the solution, respects .
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
Try clearing the ComponentModelCache, the cache will rebuild next time VS is launched.
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.
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.
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.