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
I had this trying to add an Empty API Controller in an ASP.NET Core Web Application (API template). I found in Project Properties the Target Framework wasn't set. I set it to .NET Core 2.1.
If you then try to add the controller you will get an error because this line of code was added to Startup.cs
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
and CompatibilityVersion doesn't have an enum for Version2_2, so change it to 2_1:
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
and now it adds the controller ok.
I was getting this with a totally new project. Visual Studio 2017 15.9.11.
I had already tried the dotnet restore and clearing the ComponentModelCache.