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 o
You can get the Entity Key members collection from MetaDataWorkspace using the following code:
ReadOnlyCollection keyMembers = db.MetadataWorkspace.GetType("", "Entity_Namespace", System.Data.Metadata.Edm.DataSpace.CSpace).MetadataProperties["KeyMembers"].Value as ReadOnlyCollection;