If model-first, we use [MetadataType(typeof(ConceptMetadataSource))] to attach a MetadataSource file which contains all the data annotations like [Hidden
All you have to do is create another partial class and use metadatatype attribute. Here is the sample code
//This is generated by EDMX
namespace DataLayer
{
using System;
using System.Collections.Generic;
public partial class Customer
{
public Customer()
{
this.CustomerAddresses = new HashSet();
this.CustomerOrders = new HashSet();
}
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailId { get; set; }
public Nullable DateOfBirth { get; set; }
public virtual ICollection CustomerAddresses { get; set; }
public virtual ICollection CustomerOrders { get; set; }
}
}
Add following code manually
namespace DataLayer
{
[MetadataType(typeof(CustomerMetaData))]
public partial class Customer
{
}
public class CustomerMetaData
{
[StringLength(10, ErrorMessage = "First name must be 25 characters or less in length.")]
[Required(ErrorMessage = "First name is required.")]
public String FirstName { get; set; }
}
}