using System.Collections.Generic;
public int Id { get; set; }
public ICollection<BottomEntity> Bottoms { get; set; }
public class BottomEntity
public int Id { get; set; }
public int TopId { get; set; }
public class TopEntityViewModel
public int Id { get; set; }
public ICollection<BottomEntityViewModel> Bottoms { get; set; }
public class BottomEntityViewModel
public int Id { get; set; }
public static void Main()
var mapperConfig = new MapperConfiguration(exp =>
exp.CreateMap<TopEntity, TopEntityViewModel>();
exp.CreateMap<BottomEntity, BottomEntityViewModel>();
exp.CreateMap<TopEntityViewModel, TopEntity>();
exp.CreateMap<BottomEntityViewModel, BottomEntity>()
.ForMember(dest => dest.TopId, opts => opts.Ignore());
mapperConfig.AssertConfigurationIsValid();
var mapper = mapperConfig.CreateMapper();
var topEntity = new TopEntity
Bottoms = new List<BottomEntity>
var topEntityVm = new TopEntityViewModel
Bottoms = new List<BottomEntityViewModel>
new BottomEntityViewModel
new BottomEntityViewModel
var updatedTopEntity = mapper.Map(topEntityVm, topEntity);
Console.WriteLine(updatedTopEntity.Bottoms.ElementAt(0).TopId);
Console.WriteLine(updatedTopEntity.Bottoms.ElementAt(1).TopId);
Console.WriteLine(updatedTopEntity == topEntity);