1

I am working on MVC3. not sure whether its the right question but it keeps on bothering me always.

I have a generic model used by multiple views. If i make any changes to the model variables for example name change it does not reflect in any of the views nor does it throw any compile time errors. The errors are thrown only at run time.

This can cause a serious issue if model changes are not checked for in each view manually.

Is there any way to overcome this manual changes in the view?

tereško
  • 58,060
  • 25
  • 98
  • 150

2 Answers2

1

There are two things that can help. The first is T4MVC, although this is really more about making your helpers more compile-time safe. This won't, by itself help. If you also follow these instructions then it will also compile your views and catch most of these errors.

Be aware, however, compiling views can significantly slow the build process.

Community
  • 1
  • 1
Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
0

nope... that is something you must be aware of, when "fixing" your model.

as the model gets evaluated at runtime, just like ViewBag and ViewData, you will have to update changes manually.

i guess you could update the changes with a nice "Search and Replace" though

Vogel612
  • 5,620
  • 5
  • 48
  • 73