I am using Entity Framework code First Approach so I have the mapping model like shown below.Like this I have 40 models Now I want to know the length of column such as BC_ID as shown above programmatically.How can I get max column Length ?I think we can do it using Reflection class but do not know exactly how to do it.I am using Entity Framework 5.0
public class BusinessContactMap : EntityTypeConfiguration<BusinessContact>
{
public BusinessContactMap()
{
// Primary Key
this.HasKey(t => t.BC_ID);
// Properties
this.Property(t => t.BC_ID)
.IsRequired()
.HasMaxLength(64);
this.Property(t => t.BC_FirstName)
.HasMaxLength(64);
this.Property(t => t.BC_LastName)
.HasMaxLength(64);
this.Property(t => t.BC_Mobile)
.HasMaxLength(64);
this.Property(t => t.BC_Office)
.HasMaxLength(64);
this.Property(t => t.BC_Mail)
.HasMaxLength(64);
// Table & Column Mappings
this.ToTable("BusinessContacts");
this.Property(t => t.BC_ID).HasColumnName("BC_ID");
this.Property(t => t.BC_FirstName).HasColumnName("BC_FirstName");
this.Property(t => t.BC_LastName).HasColumnName("BC_LastName");
this.Property(t => t.BC_Mobile).HasColumnName("BC_Mobile");
this.Property(t => t.BC_Office).HasColumnName("BC_Office");
this.Property(t => t.BC_Mail).HasColumnName("BC_Mail");
this.Property(t => t.Record_Instance).HasColumnName("Record_Instance");
this.Property(t =>t.Record_LastModified).HasColumnName("Record_LastModified");
}
}