title: Automapper and mapping list within a complex object / nested mappings
body: <p>I am having a heck of a time converting from older mapping standards to automapper.</p>
  
  <p>Here are my classes</p>
  
  <pre><code>// Models
  public class BaseModel
  {
      public Int64 Id { get; set; }
      public Guid UniqueId { get; set; }
      public DateTime? CreateDate { get; set; }
      public DateTime? LastUpdate { get; set; }
  } 
  
  public class LibraryItemModel : BaseModel
  {
      public string Name { get; set; }
      public string Description { get; set; }
      public string URL { get; set; }
      public bool IsActive { get; set; }
      public List&lt;LibraryCategoryModel&gt; Categories { get; set; }
  }   
  
  public class LibraryCategoryModel : BaseModel
  {
      public string Description { get; set; }
  }
  
  
  // Entity Classes
  
  public partial class LibraryItem
  {
      public LibraryItem()
      {
          this.LibraryItemCategories = new HashSet&lt;LibraryItemCategory&gt;();
      }
  
      public long Id { get; set; }
      public System.Guid UniqueId { get; set; }
      public string Description { get; set; }
      public string URL { get; set; }
      public System.DateTime CreateDate { get; set; }
      public System.DateTime LastUpdate { get; set; }
      public bool IsActive { get; set; }
      public string Name { get; set; }
  
      public virtual ICollection&lt;LibraryItemCategory&gt; LibraryItemCategories { get; set; }
  }
  // comes from a ternary table in DB... many to many
  public partial class LibraryItemCategory
  {
      public long LibraryItemId { get; set; }
      public long LibraryCategoryId { get; set; }
      public System.DateTime CreateDate { get; set; }
      public System.DateTime LastUpdate { get; set; }
  
      public virtual LibraryCategory LibraryCategory { get; set; }
      public virtual LibraryItem LibraryItem { get; set; }
  }
  
  public partial class LibraryCategory
  {
      public LibraryCategory()
      {
          this.LibraryCategoryRoles = new HashSet&lt;LibraryCategoryRole&gt;();
          this.LibraryItemCategories = new HashSet&lt;LibraryItemCategory&gt;();
      }
  
      public long id { get; set; }
      public System.Guid UniqueId { get; set; }
      public string Description { get; set; }
      public System.DateTime CreateDate { get; set; }
      public System.DateTime LastUpdate { get; set; }
  
      public virtual ICollection&lt;LibraryCategoryRole&gt; LibraryCategoryRoles { get; set; }
      public virtual ICollection&lt;LibraryItemCategory&gt; LibraryItemCategories { get; set; }
  }
  
  
      // Old Conversion code doing it the long way
  
      private LibraryItemModel Convert(Entities.LibraryItem libraryItem)
      {
  
          var newLibraryItem = new LibraryItemModel
          {
              UniqueId = libraryItem.UniqueId,
              Name = libraryItem.Name,
              Description = libraryItem.Description,
              URL = libraryItem.URL,
              CreateDate = libraryItem.CreateDate,
              LastUpdate = libraryItem.LastUpdate,
              IsActive = libraryItem.IsActive,
              Categories = new List&lt;LibraryCategoryModel&gt;()
          };
  
          foreach (var lc in libraryItem.LibraryItemCategories)
          {
              var newCategory = new LibraryCategoryModel
              {
                  UniqueId = lc.LibraryCategory.UniqueId,
                  Description = lc.LibraryCategory.Description,
                  CreateDate = lc.LibraryCategory.CreateDate,
                  LastUpdate = lc.LibraryCategory.LastUpdate
              };
  
              newLibraryItem.Categories.Add(newCategory);
          }
  
          return newLibraryItem;
      }
  
  
      // My attempt at automapper to go between the models and entities
      Mapper.CreateMap&lt;EF.Entities.LibraryItem, LibraryItemModel&gt;();
      Mapper.CreateMap&lt;LibraryItemModel, EF.Entities.LibraryItem&gt;();
            .ForMember(lim =&gt; lim.LibraryItemCategories, o =&gt; o.Ignore()
      Mapper.CreateMap&lt;EF.Entities.LibraryCategory, LibraryCategoryModel&gt;();
      Mapper.CreateMap&lt;LibraryCategoryModel, EF.Entities.LibraryCategory&gt;()
            .ForMember(lcm =&gt; lcm.LibraryCategoryRoles, o =&gt; o.Ignore())
            .ForMember(lcm =&gt; lcm.LibraryItemCategories, o =&gt; o.Ignore());
  </code></pre>
  
  <p>No matter how I configure ignores or custom mappings it seems to not like this nesting.  Any Automapper experts out there who could tell me how a mapping with a complex object like this could be done.  The enitity classes are being generated via an EF6 edmx file.</p>