In my system, I have tasks that can be assigned to contacts. Therefore, in my business logic, I have the following code:
if (_contactChanged) { task.Contact = contact; }
If no contact is specified, the contact variable is null. It is assumed that I reject the contact relationship when I submit the changes, but I noticed that this does not happen in 99% of the times when I do this (I saw it happen once, but not sequentially after repeatedly passing this code).
When I debug, I confirmed that _contactChanged is true and the internal code does not hit. However, after I walked past task.Contact = contact; I noticed that while contact is null, task.Contact is of type
{System.Data.Entity.DynamicProxies .Contact_4DF70AA1AA8A6A94E9377F65D7B1DD3A837851FD3442862716FA7E966FFCBAB9}
and still tied to previous data.
Why is the proxy not set to null and how can I make it work correctly?
source share