entity framework 5 MaxLength
I was using EF4 and a piece of code I found to get the MaxLength value from an entity like this: public static int? GetMaxLength(string entityTypeName, string columnName) { int? result = null; using (fooEntities context = new fooEntities()) { Type entType = Type.GetType(entityTypeName); var q = from meta in context.MetadataWorkspace.GetItems(DataSpace.CSpace) .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType) from p in (meta as EntityType).Properties .Where(p => p.Name == columnName && p.TypeUsage.EdmType.Name == "String") select p; var queryResult = q.Where(p => { bool match = p