Question

Im using Preview 2 of the ASP .NET MVC Framework.

Im trying out DataAnnotation attributes with my own NHibernate models but they dont seem to work.

I was under the impression that the validation is supposed to get triggered by the model binding during a post. But even thou my model binds perfectly with wrong data supplied by me, the ModelState.IsValid still returns true.

Do DataAnnotations only work with EntityFramework/Linq2Sql generated classes, or im just doing something wrong (which is probably the case) ?

Thanks in advance.

Was it helpful?

Solution

In a word, no. DataAnnotations work with any class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top