Hi, Frans. According to the documentation, this should be possible:
Dim lineItems as New EntityCollection(New POLineItemFactory)
Dim myPOLineItem as New POLineItemEntity
Dim myVendorItem as VendorItemEntity
Dim uow as New UnitOfWork2
myVendorItem = MakeNewVendorItem()
myPOLineItem.POLineItemID = Guiid.NewGuid
myPOLineItem.VendorItemID = myVendorItem.VendorItemID '<---
myPOLineItem.VendorItem = myVendorItem '<---
lineItems.Add(myPOLineItem)
uow.AddCollectionForSave(lineItems)
uow.Commit(myAdapter,True)
I get an FK Violation between POLineItem.VendorItemID and VendorItem.VendorItemID. I thought the framework should determine that the new VendorItem should get saved first, then the POLineItem, but it doesn't seem that that's the case.
Also, the FK isn't synchronized automatically when I make the entity reference myPOLineItem.VendorItem = myVendorItem, which is why I also call myPOLineItem.VendorItemID = myVendorItem.VendorItemID. Is that because myVendorItem is new?
Thanks.
Jeff...