I have a table called "JobOrder" that is added to the database using a regular EF call.
In my database, I have Job_Id as the primary key and auto increment value , so I do not need to set it, by default for the EF model it is 0.
But I need Job_Id, which was inserted into the database after calling SaveChanges ().
I tried using Refresh (), but that did not work, Job_Id for the newly inserted object is still 0.
using (ObjContext context = new ObjContext())
{
context.AddToJobOrder(order);
context.SaveChanges();
context.Refresh(RefreshMode.StoreWins, order);
context.Refresh(RefreshMode.StoreWins, context.JobOrder);
}
I tried both calls, as mentioned above, but still I ended up Job_Id equal to 0.
Any help would be greatly appreciated.
source
share