How to get Razor intellisense for @model in a class library project
Many of us follow a modular architecture and create MVC3 Razor view in a separate class library project.
Following is a screenshot of the class library project that I have created.
Now if I open a view with @model typed in it, I notice that it shows squiggle for @model and no intellisense is shown. (error: There is build provider registered for the extension ‘.cshtml’)
The reason behind the error is that Visual Studio 2010 (for Razor tooling) requires web.config file (with some specific settings) to be in the project so that the MVC Razor host (which adds the @model directive) gets registered correctly.
The workaround would be to drop the attached web.config (rename the attached file from web.txt to web.config) to the root of the project. Close, reopen the file and Boom, intellisense is back for @model inside the class library project.
Hope this helps,