I wish to get a list of columns names, types and whether the column is a PK of a table object in Entity Framework.
How do I do this in C# (4.0) (ideally generically)
If you do not want to use reflection, see answer here. Replace entity name below with your entity name
var cols = from meta in ctx.MetadataWorkspace.GetItems(DataSpace.CSpace)
.Where(m=> m.BuiltInTypeKind==BuiltInTypeKind.EntityType)
from p in (meta as EntityType).Properties
.Where(p => p.DeclaringType.Name == "EntityName")
select new
{
PropertyName = p.Name,
TypeUsageName = p.TypeUsage.EdmType.Name, //type name
Documentation = p.Documentation != null ?
p.Documentation.LongDescription : null //if primary key
};