Getting Started with T4MVC

This post is about T4MVC and how you would use it within your MVC application. T4MVC is a great way to generate strongly typed helpers so you can eliminate the use of literal strings when referring to Actions, Controller, and Views within your MVC application.

How to install T4MVC?

You have 2 options.

a.    Download from MvcContrib CodePlex project.

b.    Use NuGet


NuGet Approach      

Open VS2010. Tools,  Library Package Manager, and Package Manager Console. Execute the following command.

PM> install-package T4MVC

This should install 2 files under your app’s root folder. and – These files contain necessary entries which allow you to use T4 strongly typed helpers.


Once you install T4MVC, you might also notice couple errors appeared in the Error List window. (Please see below)  image

As you see, there are no auto generated files being added to the solution yet. You would continue to get these errors if you decided to build the solution.

To remove these errors, you need to run Custom Tool on the file. (Right click on the file and select “Run Custom Tool”).Now you should be able to see additional auto generated files added to the solution.


T4MVC in Action

Below are few examples of the usage of T4MVC.

image (1)


As you see T4MVC generates the strings accordingly.

Where to find more information?

T4MVC templates are part of MVCContrib project and developed by David Ebbo. If you would like to know more information please visit the link below.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s