I have some POCO objects that I use in the context of EF Code First. Therefore, when I populate them with data, I am actually dealing with EF proxy objects, not the POCO itself.
I have an ASP.NET MVC4 ApiController that returns my POCO objects that I will use in my client application.
My "get" method looks something like this:
public Client GetClient(int id)
{
Client client = db.Clients.Find(id);
if (client == null)
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
}
return client;
}
This actually does not work, because when the serializer tries to serialize the Client object, it actually deals with the version of the EF proxy that causes its hiccups. See Can ApiController return an object with a collection of other objects?
So, I can turn off proxy generation by doing this with DbContext:
db.Configuration.ProxyCreationEnabled = false;
, POCO, . Client , - EF, .
EF , POCO .
( ) ? , , , ?