I come across a situation where i need to insert the data in the database & simultaneously require the primary id using entity framework.
Solution :
long id;
IGenericQueryRepository InfoBase = null;
try
{
InfoBase = new GenericQueryRepository();
InfoBase.Add(generalinfo);
InfoBase.Context.SaveChanges();
id = entityclassobj.ID;
return id;
}