title: Entity Framework + AutoMapper ( Entity to DTO and DTO to Entity )
body: <p>I've got some problems using EF with AutoMapper. =/</p>
  
  <p>for example :</p>
  
  <p>I've got 2 related entities ( Customers and Orders )
  and they're DTO classes :
   <pre>
  <code>
  class CustomerDTO
  {
     public string CustomerID {get;set;}
     public string CustomerName {get;set;}
     public IList&lt; OrderDTO > Orders {get;set;}
  }</p>
  
  <p>class OrderDTO
  {
     public string OrderID {get;set;}
     public string OrderDetails {get;set;}
     public CustomerDTO Customers {get;set;}
  }</p>
  
  <p>//when mapping Entity to DTO the code works
  Customers cust = getCustomer(id);
  Mapper.CreateMap&lt; Customers, CustomerDTO >();
  Mapper.CreateMap&lt; Orders, OrderDTO >();
  CustomerDTO custDTO = Mapper.Map(cust);</p>
  
  <p>//but when i try to map back from DTO to Entity it fails with AutoMapperMappingException.
  Mapper.Reset();
  Mapper.CreateMap&lt; CustomerDTO , Customers >();
  Mapper.CreateMap&lt; OrderDTO , Orders >();
  Customers customerModel = Mapper.Map&lt; CustomerDTO ,Customers >(custDTO); // exception is thrown here
  </code>
  </pre></p>
  
  <p>Am I doing something wrong?</p>
  
  <p>Thanks in Advance !</p>