Search code examples
asp.net-mvct4mvc

ASP.Net T4MVC file not updating itself


I am wokring in ASP.Net MVC (.Net 4.0) with T4MVC template.

So far this file was getting updated with entries automatically whenever I used to add new files into my project (like controllers, views, etc.).

But for some reason, it has stopped updating itself. I have just added new folder into project with 3 aspx files and also related controllers and models. But still T4MVC does not show these things at all and the compiler gives errors for missing things.

Can anybody please help me figuring out the reason?

Thanks!


Solution

  • T4MVC will not update itself.

    You have to Right-Click the .tt files in your solution explorer and click Run Custom Tool.

    When you do this, your solution will also compile.

    T4MVC changes all your controller methods to virtual and writes overrides for them. So when you compile sometime, T4MVC will have a compile error, thats probably because you renamed or changed the signature of a method in your controller. Delete this method off from T4MVC and click Run Custom Tool to regenerate.

    See this answer for details on T4MVC:
    ASP.NET MVC3 How to reference views directly from controller