title: Automapper -- mapping many-to-many lookups from Entity Framework to viewmodel
body: <p>I believe this is an AutoMapper basics question:</p>
  
  <p>I have an single "article" Entity Framework entity that I am mapping to a viewmodel to pass to a view for edits. This works fine:</p>
  
  <pre><code>Mapper.CreateMap&lt;Article, ArticleAdmin&gt;();
  var articleData = Mapper.Map&lt;Article, ArticleAdmin&gt;(articleEntity);
  </code></pre>
  
  <p>Now, my EF model includes many-to-many relation to a Topics table via a TopicArticles lookup table, and I want to manage associations when I'm editting the article data.</p>
  
  <p>So I add this to my viewmodel:</p>
  
  <pre><code>public ICollection&lt;TopicArticle&gt; TopicArticles { get; set; } 
  </code></pre>
  
  <p>I believe this is correct specification to mirror the entity type -- my EF model has the TopicArticles association member as an EntityCollection. </p>
  
  <p>and I add a second viewmodel class to populate the list:</p>
  
  <pre><code>public class TopicArticle
  {
      public int ArticleId { get; set; }
      public int TopicId { get; set; }
      public bool IsPrimaryTopic { get; set; }
  }
  </code></pre>
  
  <p>When I run the mapping, I get "Missing type map configuration or unsupported mapping." Which is understandable as I've not told Automapper about my TopicArticle viewmodel class. </p>
  
  <p>So:
  QUESTION:  </p>
  
  <p>How do I change my mapping to account for this extra layer? </p>
  
  <p>(I don't really understand the Automapper syntax for how this should be mapped.)</p>
  
  <p>Also: have I missed anything else?</p>
  
  <p>NOTE / UPDATE:</p>
  
  <p>There were some errors in my posted code, any "publication" that appeared was incorrect, and should have been "article" -- that was because I'm simplifying the situration a bit: articles actually inhereit from publications, but I did not want that complexity in this Question.</p>