DbContext corrupts attached entities: why?
===

I've got some code like this:

    Activity[] GetAllActivities() {
      using (ScheduleContext ctx = new ScheduleContext())
        return ctx.Activities.AsNoTracking().ToArray();
    }

The aim to have a very simple in-memory cache of some data: `Activities` is mapped to a db view which summarizes everything I need.

If I *omit* `AsNoTracking` the returned objects are non-deterministically corrupted: properties on the returned objects aren't set correctly, and frequently one object's property value is duplicated in other objects' properties.  There's no warning or exception; neither on EF4.3.1 nor EF5rc2.  Both CLR 4 and the 4.5 release candidate exhibit the same behavior.

The `Activity` objects are very simple; consisting solely of non-virtual properties of basic type (`int`, `string`, etc.) and have no key nor a relationship with any other entity.

Is this expected behavior?  Where can I find documentation about this?

I understand that obviously change tracking cannot work once the relevant `DbContext` is gone, but I'm surprised the materialized properties are corrupted without warning.  I'm mostly worried that I'll forget `AsNoTracking` somewhere in a more complex scenario and get somewhat plausible but wrong results.




