ASP.NET MVC & ADO.NET Entity Framework clientside validation
Posted
by JK
on Stack Overflow
See other posts from Stack Overflow
or by JK
Published on 2010-04-28T02:37:39Z
Indexed on
2010/04/28
2:43 UTC
Read the original article
Hit count: 327
asp.net-mvc-2
|entity-framework
Using aspnet mvc2 with the model auto-generated by entity framework:
Is it possible to tell entity framework to auto-annotate all fields? eg:
If database field says not null then add [Required] If DB field is a nvarchar(x) then add [StringLength(x)]
And so on?
What if the field name contains the string "email" eg CustomerEmail - can I get EF to auto-annotate that with an appropriate annotation ([Regex()] maybe)
As I understand it, if the model fields are annotated, and I use both Html.ValidationMessageFor() and use if (ModelState.IsValid) in my controller, then that is all I need to do to have basic clientside input validation working?
Thanks
© Stack Overflow or respective owner