RavenDB: Just add your annotations to your model

ASP.NET MVC,RavenDB 18 January 2012 | 0 Comments

Yesterday whilst chatting in the RavenDB room on JabbR I had a brainwave and it was confirmed by the guys there.

I should add my model annotations (Required, DisplayName etc) to my model because RavenDB doesn’t care!

For example, take this model:

It then means I have to write a view model to describe the requirements and how its displayed. Like this:

Validation like being required are duplicated and mistakes can happen when defining labels or they become inconsistent.

My simple solution. Just add those attributes to your model, RavenDB doesn’t care. Sure there might be cases where you need something different, but 95% of the time it is saving me work!

Leave a Reply