I have a table "JobOrder" which is added to the database using normal EF call.
In my database, i have the Job_Id as primary key & auto increment value so i do not need to set it which the EF model defaults it to 0.
But I am in need of the Job_Id that has been inserted to database after i call SaveChanges().
I tried using Refresh() but it did not work, the Job_Id for newly inserted object was still 0.
using (ObjContext context = new ObjContext())
{
context.AddToJobOrder(order);
context.SaveChanges();
context.Refresh(RefreshMode.StoreWins, order); //TRIED THIS
context.Refresh(RefreshMode.StoreWins, context.JobOrder); //TRIED THIS TOO
}
I tried both calls as mentioned above, but still i ended up having Job_Id to be 0.
Any help would be greatly appreciated.