One possibility is to trick Visual Visual Studio into thinking that your class library is an ASP.NET MVC application. For example in VS 2013 and ASP.NET MVC 5 you could open your class library .csproj
file in your favorite text editor (notepad.exe in my case) and add the following just after the <ProjectGuid>
tag:
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
and replace:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
with:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
Now reload your solution in Visual Studio and you will be find some new context menus when you right click on your class library project.
But to be honest, why would you wanna rely on some magic to write the code for you instead of writing it yourself?