So you say that this should save related entities too?
EntityManager.SaveChangesAsync(new List<Entity>(){ MyParentEntitie }, ....) |
If I don't add related entities to list of entities that should be saved it fails with:
An entity or entities containing a referenced temporary Id is missing from the list of entities provided. Missing entities include: MyEntityType: -101. See exception members for more details |
But when I add them manually it inserts them in DB and still throws error (that's interesting, because it actually inserts relations into DB) on FK.
I removed FK and it goes like this:
It first saves ParentEntity ok, and then it saves related entities, but it tries twice for each. First (I guess it's first, because it should fail otherwise on first error) it saves with the right foreign key, and then tries to save it again with -100 for foreign key (this is internal for ParentEntity). Now I have two questions:
1. Why it tries to save it twice?
2. Shouldn't that SaveChanges work in a transaction? How can than happen that something is saved when error occurrs?
Edit: the above only happens when adding, when updating it works like expected
Edited by redman - 15-Jun-2012 at 12:28am