I would like to get the KeyMembers
where I have set in the Edmx the StoreGeneratedPattern
to Identity
is there a way to do this?
I can get the KeyMembers with this code:
private static IEnumerable<EdmMember> GetKeyMembers(string entityName)
{
var objectContext = EntityModel.ObjectContext;
var metaData = objectContext
.MetadataWorkspace
.GetEntityContainer(objectContext.DefaultContainerName, DataSpace.CSpace)
.BaseEntitySets
.FirstOrDefault(x => x.ElementType.Name == entityName);
return metaData.ElementType.KeyMembers;
}
The problem I have with this that it also returns foreign keys, but I just want to get PrimaryKeys with auto incrementing values.