• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Visual Editor for DataAnnotations ASP.NET MVC?

Bulldog13

Golden Member
I am writing DataAnnotations for my models in my MVC program. After doing pretty much the same thing for the third model, I can't help but wonder is there an easier way to do this?

Code:
    [MetadataType(typeof(ArticleMD))]
    public partial class Article
    {
        public class ArticleMD
        {
            [DisplayName("Created By:")]
            public string CreatedBy { get; set; }

            [DisplayName("Additional Information:")]
            [DataType(DataType.MultilineText)]
            public string AdditionalInformation { get; set; }

            [DisplayName("Title:")]
            [Required]
            public string Title { get; set; }
//...

Does anyone know of any addons or plugins for Visual Studio that would allow you to select a Model or ViewModel and use a GUI to define all of this stuff (in a separate Metadata class)?
 
I don't really see the added value of a visual designer.

If you're working against an EF class (not code-first) then the metadata class is a must, however when working against a ViewModel I don't really see the need.

As stated in your SO post, http://stackoverflow.com/questions/5844589/visual-editor-for-dataannotations-asp-net-mvc , I don't think a GUI would make it any faster, maybe a t4 template to read EF classes would...


It probably wouldn't be any quicker, but sometimes I get sick of staring at a wall of text.
 
If you 're doing it a lot, might be worth whipping up some short cuts in Excel. Have the various attributes be drop downs or check boxes. You just type the property name into the first column, select it's data type, check the boxes for required, min length, etc. Then when all done, copy/paste from an output column into VS.
 
Back
Top