title: Need to verify Autommaper implemented correctly in Asp.Net MVC
body: <p>I have implemented Automapper in my MVC project but not sure if it is been done correctly. I am currently using Entity Framework Database First Approach and retrieving data using stored  procedures. As you would be aware Entity Framework creates complex type object which is a wrapper around Stored Procedures.So I have created two classes for mapping purpose. One is used in the repository class to map the complex type to Entity class and second is the viewmodel that is used to map the entity class to view model in the controller. I havent explicitly mapped my entity class to viewmodel in the controller. So I am wondering how is the data bound to the grid as the grid is expecting viewmodel. I am looking forward for suggestions in terms of the approach that I have taken. </p>
  
  <pre><code>spGetUserProfileByUserProfileID_Result - Complex type object
  UserProfile                            - Entity class.
  UserProfileViewModel                   - ViewModel  
  </code></pre>
  
  <p><strong>AutoMapperConfiguration Class</strong></p>
  
  <pre><code>  public static void Configure()
          {
              Assembly[] assemblies = BuildManager.GetReferencedAssemblies().OfType&lt;Assembly&gt;().ToArray();
              Mapper.Initialize(cfg =&gt;
              cfg.AddProfiles(AllClasses.FromAssemblies(assemblies)
              .Where(
              a =&gt;
                 a.FullName.EndsWith("Mapping"))));
          }
  </code></pre>
  
  <p><strong>Mapping class</strong></p>
  
  <pre><code>public class DomainToModelMapping : Profile
      {
          public DomainToModelMapping()
          {
  
              CreateMap&lt;spGetUserProfileByUserProfileID_Result, UserProfile&gt;().ReverseMap();
              CreateMap&lt;UserProfileViewModel, UserProfile&gt;().ReverseMap();
  
          }
      }
  </code></pre>
  
  <p><strong>Repository</strong></p>
  
  <pre><code> public List&lt;UserProfile&gt; GetUserProfileById(int id)
          {
              if (MCRHelper.UserValidate() == 1)
              {
                  var userProfiles = db.spGetUserProfileByUserProfileID(id);
  
  
                  return Mapper.Map&lt;List&lt;UserProfile&gt;&gt;(userProfiles);
              }
              else
              {
                  return null;
              }
          }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>  public ActionResult UserProfile_Read([DataSourceRequest]DataSourceRequest request)
          {
              var response = mcrRepository.GetUserProfileById(0).ToDataSourceResult(request);
              return Json(response, JsonRequestBehavior.AllowGet);
          }
  </code></pre>
  
  <p>If I add the following , to my controller to map to viewmodel, I get an error  Missing type map configuration or unsupported mapping.</p>
  
  <p>Mapping types:
  DataSourceResult -> UserProfile
  Kendo.Mvc.UI.DataSourceResult -> CC.GRP.MCRequest.Models.UserProfile </p>
  
  <pre><code>var userProfile = mcrRepository.GetUserProfileById(0).ToDataSourceResult(request);
  
              return Json(Mapper.Map&lt;UserProfile&gt;(userProfile), JsonRequestBehavior.AllowGet);
  </code></pre>