Tuesday 28 May 2013

MVC 4 - Database first - Adding validations, etc

Watch online:

1. I have table called User
2. After adding EF, user partial class has been created (you may have to rebuild application)
3. Create another user partial class with the same namespace
     [MetadataType(typeof(UserMetaData))]
    public partial class User
    {

    }

    public class UserMetaData{
       [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
        public Nullable<System.DateTime> LastUpdate { get; set; }
    }
4. This way after updating EF from DB - this partial class stays the same

No comments:

Post a Comment