I added ResetEntityAsNew(newEntity); after the for loop that calls ResetEntityAsNew() on the ordered list. It did not affect the outcome.
Remember, I'm able to successfully SaveEntity on the cloned object immediately after the failing SaveEntityCollection. I just tried calling SaveEntityCollection again instead of looping through SaveEntity, it worked. I made an extension method:
int SaveEntityCollectionWithClones(this DataAccessAdapter adapter, IEntityCollection2 collection)
{
int num_saved=0;
int last_num_saved = -1;
while(num_saved < collection.Count && num_saved != last_num_saved)
{
last_num_saved = num_saved;
num_saved += adapter.SaveEntityCollection(collection);
}
return num_saved;
}
With various extra prints, and adding a second clone, I've determined that I'm only getting one entity saved at a time, and they are progressing in index order.
How do I set up to get the Trace output?