All my entities has property Id. All my tables in database has auto-generated integer identity Id as primary key.
I have generic method to Create entities.
I
The solution:
public override TR Create(T entity)
{
string entitySet = GetEntitySetName();
_context.AddObject(entitySet, entity);
_context.SaveChanges();
//Returns primaryKey value
return (TR)context.CreateEntityKey(entitySet, entity).EntityKeyValues[0].Value;
}
Where T: entity type, TR: entity PK type.