I have a mvc project with a wcf and I am trying to automapper 5.2 passing from DTO to ViewModel of views and gives me the following error.
AutoMapperConfiguration.cs
public class AutoMapperConfiguration
{
public static void Configure()
{
Mapper.Initialize(x =>
{
#region VM a Dto
x.CreateMap<UserProfileVM, UserProfile>().ReverseMap();
x.CreateMap<PaginaVM, PaginaDto>().ReverseMap();
#endregion
#region Dto a VM
x.CreateMap<UserProfile, UserProfileVM>().ReverseMap();
x.CreateMap<PaginaDto, PaginaVM>().ReverseMap();
#endregion
});
}
}
Global.asax
protected void Application_Start()
{
// configurar la Base de Datos
System.Data.Entity.Database.SetInitializer(new WebCodeSampleData());
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// configurar el AutoFac
Bootstrapper.Run();
// configurar AutoMapper
AutoMapperConfiguration.Configure();
}
homecontroller.cs
PaginaDto dto = _paginaService.GetByUrlCache(url);
meta = Mapper.Map<PaginaDto, PaginaVM>(dto);
PaginaDto.cs and MaginaVM.cs
public class PaginaDto
{
public int PaginaId { get; set; }
public string Url { get; set; }
public string Controller { get; set; }
public string Accion { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Keywords { get; set; }
public string Description { get; set; }
}
Error
Missing type map configuration or unsupported mapping.
Mapping types:
PaginaDto -> PaginaVM
WebBase.Model.Dto.Models.PaginaDto -> WebBase.Web.Models.Shared.PaginaVM
Which can happen since I have it mounted on the WCF Service with DTO to Entity and it works correctly