When I create new entities in a context, I cannot get a proxy even if I request it again. I have to dispose of the context and make a new one. Is this an expected behavior or am I doing something wrong?
int id = 0;
using (var context = new MyContext())
{
var A = context.People.Add(new Person{ Name = "Bob" }); // A is not a proxy
context.SaveChanges(); // A is still not a proxy
var B = context.People.Where(o => o.Id == A.Id).Single(); // B is not a proxy
id = A.Id; // Keep the ID to use with a new context
}
using (var context = new MyContext())
{
var C = context.People.Where(o => o.Id == id).Single(); // C is a proxy!
}