I Know this question was answered in another thread. And I tried what was suggested but it still not working.
Here is my entity and model mapping...
cfg.CreateMap<DocumentAmountModel, InputDocumentData>()
.ForMember(d => d.Amounts, o => o.MapFrom(s => s.Amounts));
Mapping for the child Amounts
cfg.CreateMap<ItemAmountModel, Amount>()
//Ignore the Keys for update
.ForMember(a => a.Id, o => o.Ignore())
.ForMember(a => a.ItemId, o => o.Ignore())
And I am trying to ignore the PKs and FKs in the entity from being updated with what is in model.
On the service layer- the entity is loaded with data from Db and then calling the mapper to update all the property other than FK & PK as follows.
var doc = _docDataR.GetAll()
.Where(d => d.Id==1)
.SingleOrDefault<InputDocumentData>();
Mapper.Map<DocumentAmountModel, InputDocumentData>(model, doc);
To my surprise, Amount.Id and Amount.ItemId are always updated with 0 on the child Amounts. Am missing anything obvious?
PS: The entity instance "doc" is not proxy, so it is not about being proxy that could have caused improper mapping.