Look at the method signature. IN...
Mapper.CreateMap<Role, RoleDto>() .ForMember(x => x.Users, opt => opt.Ignore()) .ForSourceMember(x => x.Users, opt => opt.Ignore());
... ForMember is a method that expects an Expression<Func<RoleDto>> parameter named destinationMember , while ForSourceMember expects an Expression<Func<Role>> parameter named sourceMember . So
ForMember configures the members of the target type.ForSourceMember configures source type members.
In your case, both the source and target types have UserId members, so the calls look the same, but they are not. They should do the same, but the funny thing is that ForSourceMember doesn't seem to have any effect when ignoring members. Perhaps this is a mistake.
source share