Reputation: 3383
ASP.NET Web API project template in Visual Studio 2012 is a specialized MVC4 project and after creating an instance of such a project, right clicking on the "Controllers" folder shows you "Add >> Controller" menu item which triggers the controller generator. (scaffolding)
On the other hand, it is also possible to host an ASP.NET Web API server in a console application, which is called in the documentation a Self-Host application.
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/self-host-a-web-api
My question is: How can I use the "Controller Scaffolding" if I am developing a self hosting console application?
Upvotes: 2
Views: 1826
Reputation: 12194
Scaffolding is still supported via the package manager console e.g. here.
But the MVC specific "Add Controller" dialog is indeed reserved for MVC project files.
You can however, force your self host project to include this dialog.
This can be achieved by adding a line into the project file to "trick" visual studio into thinking your self host app is a MVC app. See this question for details "Add Controller" / "Add View" in a hybrid MVC/WebForms ASP.NET application
If you:
Right mouse button your self host project file click reload project
<ProjectTypeGuids>
{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
Once you have done this you can start playing around with TT files (scaffolds) to make them more useful/specific to self hosting http://www.hanselman.com/blog/ModifyingTheDefaultCodeGenerationscaffoldingTemplatesInASPNETMVC.aspx
Upvotes: 1
Reputation: 929
I don't think this is currently possible. This scaffolding support is specific to MVC 4 projects currently.
Upvotes: 0