Cannot making new controller after upgrade Visual Studio 2019 - asp.net-mvc

I cannot create a new controller on my ASP.NET MVC API. When I try to create a new controller, Visual Studio 2019 always throws an error (as shown in the screenshot):
I used Microsoft Visual Studio 2017 before, and it worked normally. But after upgrade, I have several issues with this IDE like creating controller in my existing project and cannot create a new ASP.NET Core MVC web application.
Hopefully anyone can help me.
Thanks in advance

That error message means there is no relative templates when you try to add the controller using visual studio wizard.
Try to install MVC 4 Package.
This link might be helpful too Modify Visual Studio

Related

Empty .NET Core 2.0 project with MVC template in Visual studio 2017

Today I migrated from Visual studio 2015 to Visual studio 2017.
In visual studio 2015 whenever I wanted to create a new web project not only was I able to choose it as an empty project but also I was able to indicate my empty project be in which template by clicking on diverse check boxes in new project window. For example I was able to create a MVC project which all folders were empty.
I can not find this facilities in Visual studio 2017. If I choose a MVC project in new project windows it creates some default styles, views, and controller which I don't like. If I choose empty project then it don't have Model,View and Controller folders either.
So am I able to create an Empty + MVC + .Net Core 2 project in Visual studio 2017 or Microsoft simply removed this feature?
UPDATE
I have tried to first create an empty project and then add MVC to it by installing Microsoft.AspNet.Mvc through NUGET. But it just added MVC dependencies to my project. Am I have to create all needed folders (model, view, controller, shared....) manually? Its really frustrating.
I believe I have installed .NET Core properly. This screenshot of my New project window is a proof of that.

Visual Studio (2013/2015/2017) WebAPI issue (add mvc controller menu disappeared after add APIController to project)

Since I've added WebAPI to my existing ASP.NET MVC 4 project, when I want to add a new MVC controller, I am unable to do so because Visual Studio will only show the WebAPI controller creation dialog.
Is there any solution to this problem? (I have tested it in both 2013 and 2015)
Updated
I have also test it in VS 2017, it has this issue likewise !

Unable to create MVC View using scaffolding in Visual Studio 2013 Ultimate Update 5

I recently applied Update 5 to Visual Studio 2013 (Ultimate Edition) running on Windows 8.1. After the update, any time I try to create a Razor View (*.cshtml) file in my MVC application using scaffolding, I get the following error:
There was an error running the selected code generator:
The Templates\PackageVersion5.1.3.xml file is missing from the
installed template folder
From the error, it is clear that some file (PackageVersion5.1.3.xml) is missing but I'm not sure how to fix it. I even repaired Visual Studio but to no avail.
As yoo probably know during scaffolding your view is generated base on this missing xml file. I don't know why your file is not there but you can copy it from one of your colleagues computer or reinstall visual studio.
Maybe you have change something i VS options?
I avoid the scaffolding options in Visual Studio.
Why? In my experience, the standard MVC pattern where everything separated by type will always led to a difficult to manage and test solution.
Instead, I now prefer to organise MVC projects by feature (http://timgthomas.com/2013/10/feature-folders-in-asp-net-mvc/).

How do I open an old MVC project in Visual Studio 2012 or Visual Studio 2013?

I have an old ASP.NET MVC 2 project which I do not want to upgrade to MVC 3 or MVC 4. I am working on a new machine running Windows 8, Visual Studio 2012 and Visual Studio 2013. When I try to open the MVC 2 project in VS 2012 or VS 2013 I receive the error:
This project is incompatible with the current edition of Visual Studio
The project is then unloaded and grayed out in Solution Explorer. I do not want to install another copy of Visual Studio. How can I open an old MVC project in a new version of Visual Studio?
Opening an unsupported MVC project in Visual Studio 2012 or Visual Studio 2013 is actually pretty easy to accomplish with two steps. In fact, as bytebender’s comment indicates, these same steps should apply to and work for MVC 1 projects. However, I haven’t tested them and therefore cannot guarantee that they do in fact work.
Assuming that you have not already done so step one is to download and install MVC 1, MVC 2 or MVC 3 (close Visual Studio before starting the installation).
Once you have the appropriate flavor of MVC installed the project will still not load in VS 2012. This is because ASP.NET MVC projects are a project subtype of the Web Application project type. This means that the project has additional add ins and features available to it when used within Visual Studio.
Both Visual Studio 2012 and Visual Studio 2013 are limited in their backwards compatibility with ASP.NET MVC and other project types. Unfortunately, installing the old MVC bits did not change that. Visual Studio 2012 is compatible with the ASP.NET MVC 3 and 4 project flavors. Visual Studio 2013 is compatible with MVC 4 and MVC 5.
To get the project to load you will have to modify the project file. To do so right click on the unloaded project and select Edit. Which will open the project file as an XML text file. Find the ProjectTypeGuids node which should look something like this:
<ProjectTypeGuids>
{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
Remove the appropriate Project Guid from the list:
ASP.NET MVC 1: {603c0e0b-db56-11dc-be95-000d561079b0}
ASP.NET MVC 2: {F85E285D-A4E0-4152-9332-AB1D724D3325} (shown in example above)
ASP.NET MVC 3: {E53F8FEA-EAE0-44A6-8774-FFD645390401}
ASP.NET MVC 4: {E3E379DF-F4C6-4180-9B81-6769533ABE47}
With the appropriate GUID removed the ProjectTypeGuids should look similar to this:
<ProjectTypeGuids>
{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
Save the file and close the Visual Studio project file editor. Right click the project and select reload. If the project does not reload close and reopen Visual Studio. You should now be able to work with your old ASP.NET MVC project in your new version of Visual Studio.
One important thing to note is that after these modifications Visual Studio is not aware that this is an ASP.NET MVC project; therefore the project-specific features like "Add Controller, View etc." will not be present in menus.
I used #ahsteele's approach (thanks and 2x+1s!), but was having one further error:-
.csproj : error : The operation could not be completed. Invalid class string
I can't find any citations for the real cause of that, but I was able to get VS2012RTM to load the project successfully by changing the <ProjectGuid>. (No idea how this happened - its part of a large solution and VS08, VS10, VS11 Beta and VS2012RC have all upgraded the .csproj and .sln over time.
In VS2017 the solution is to just make it like <ProjectTypeGuids></ProjectTypeGuids> so.
No Spaces in between ladies and gentlemen, otherwise it will waste 48 hours of your time.
Regards

Visual Studio 2010 MVC Project type Disappeared

I have been working with visual studio 2010 Premium RTM for over a month. When I installed it I had a fresh install of windows. (No betas or previous versions of VS)
I have been creating new ASP.NET MVC2 C# projects since I installed it. I went to create a new mvc project today and I don't have that as an option anymore. I went in under the new project section not the new website section. I don't see it listed under C# or VB.
Is there a way to get that back without reinstalling visual studio?
I had this problem with Linq to SQL templates. Try the accepted answer on this other stack overflow question.
The solution was to run
devenv.exe /InstallVSTemplates
to reinstall the templates. It worked for me when I had missing templates in Visual Studio 2010.

Resources