I have the following sample entities:
public class User { public string Username { get; set; } public string Password { get; set; } pubilc HashSet<UserRole> Roles { get; set; } } public class Role { public string RoleName { get; set; } public HashSet<UserRole> Users { get; set; } } public class UserRole { public int UserId { get; set; } public virtual User User { get; set; } public int RoleId { get; set; } public virtual Role Role { get; set; } } and the following Dtos:
public class UserModel { public string Username { get; set; } public string Password { get; set; } pubilc HashSet<RoleModel> Roles { get; set; } } public class RoleModel { public string RoleName { get; set; } public HashSet<UserModel> Users { get; set; } } with the following AutoMapper configuration:
CreateMap<User, UserModel>(); CreateMap<Role, RoleModel>(); CreateMap<UserRole, UserModel>() .ConstructUsing((src, ctx) => ctx.Mapper.Map<UserModel>(src.User)); CreateMap<UserRole, RoleModel>() .ConstructUsing((src, ctx) => ctx.Mapper.Map<RoleModel>(src.Role)); but this configuration causes the iis to stop without any error!
Is this configuration right for mapping one source into multiple destinations?



MapperConfiguration, ran it, and configuration was created without errors. Please make a small test project and copy there only the code you feel is relevant and investigate from there.