How to get first EntityKey Name for an Entity in EF4
问题 How can I get the 1st EntityKey name for an Entity for Entity Framework 4 because I'm building a repository system and I wanted to get an item by Id (which is the primary key oin EF is the 1st entitykey for the entity) I'm using this code public virtual TEntity GetById(string keyName, Guid entityId) { var entityKey = new EntityKey(this.QualifiedEntitySetName, keyName, entityId); object entity; return this.Context.TryGetObjectByKey(entityKey, out entity) ? entity as TEntity : null; } I want to