Can you post a code sample of your memory stream solution. Also, there are issues with your sample of marking the fields IsChanged property:
1. You cant set IsChanged if the field was NULL because it will try to save DateTime.MinValue if it was a date field and that blows up in SQL Server.
2. You cant set IsChanged on a timestamp column because that will also blow up.
Basically your example dosent work, but this seems to...
MyEntity copy = new MyEntity();
copy.Fields = (IEntityFields2)((EntityFields2)entityToCopy.Fields).Clone();
copy.IsDirty = true;
//Note this will skip the last column which is our timestamp
for(int i=0;i<copy.Fields.Count-1;i++)
{
if(!copy.Fields[i].IsNull && !copy.Fields[i].IsPrimaryKey)
{
copy.Fields[i].IsChaged = true;
}
}
Now that this is working we still need to do a deep copy of all the related entities. If you could post an example of your idea that would be great!!!