Framework Madness!

And other adventures C# and …

Archive for July 2009

Data Annotations : MVC 2 Preview 1

with 4 comments

That title is a mouth full.

Moving on – if you don’t know by now the MVC team posted their first draft of v2 last night along with a few blogs posts and a Scott Hanselman Channel 9 video. And while the first hint at Areas looks incomplete, the work on Data Annotations looks very promising.

I have been doing a major eCommerce project at work leveraging 3.5 Dynamic Data along with Entity Framework for the admin. Using Dynamic Data has really cut my development time and I couldn’t fathom leveraging MVC without similar support. Well, MCV v2 Data Annotation support thus far appears similar but stripped down like the MCV types like it. Support comes from several improvements:

  • Display and Editor Templates: these are user controls that can be used to create display and editing output for properties specified by Data Annotations applied to the model. These are similar to field templates. However, they can be used for more than just values types, you can make controls for complex types as well.
  • Strong Typed UI Helpers: these extensions of the Html object inside a view not only allow for using lambda expressions for specifying output but also act as the gateway to leveraging Display and Editor templates. And of course using lambda expressions adds compile time support.
  • Data Annotation Validation: model validation now supports data type validations in the controller and returning the same view returns the correct validation error messages.

This really gets my interest in MVC going. The lack of controls is frustrating but I could live with out them. I cannot however live with out Data Annotation UI and validation support so this makes MVC much more approachable in the near term. The rest of the details are in the revised road map.

It looks like future previews will improve on all current features and add a few additional things to boot. How much get’s added to MVC v2 ultimately will be limited by the teams stated goal of being on the  VS 2010 DVD which will probably ship next spring.

More information:


Written by Lynn Eriksen

July 31, 2009 at 6:39 am

Posted in Uncategorized

Tagged with , ,