The key property of an entity class is marked with this attribute:
[EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
, EntityKeyProperty true. T id:
PropertyInfo p = typeof(T).
GetProperties().FirstOrDefault(
x => x.GetCustomAttributes(typeof(EdmScalarPropertyAttribute), false)
.OfType<EdmScalarPropertyAttribute>()
.Where(y => y.EntityKeyProperty == true)
.Count() > 0);
return _entitySet.FirstOrDefault(x => (int)p.GetValue(x, null) == id);