I have two entities and I need to do an automapper but it is not working:
I have configured the map:
public static class AutoMapperWebConfiguration
{
public static void Configure()
{
ConfigureUserMapping();
}
private static void ConfigureUserMapping()
{
Mapper.CreateMap<MyEntity, MyEntityDTO>().ReverseMap();
}
}
MyEntity:
public class MyEntity : MongoRepository.Entity
{
public string Name { get; set; }
}
MongoRepository.Entity:
// Summary:
// Abstract Entity for all the BusinessEntities.
[Serializable]
[BsonIgnoreExtraElements(Inherited = true)]
public abstract class Entity : IEntity<string>
{
protected Entity();
// Summary:
// Gets or sets the id for this object (the primary record for an entity).
[BsonRepresentation(BsonType.ObjectId)]
public virtual string Id { get; set; }
}
MyEntityDTO:
public class MyEntityDTO
{
public string Id { get; set; }
public string Name { get; set; }
}
Trying to map:
var edto = new MyEntityDTO {Id = Guid.NewGuid().ToString(), Name = "Test"};
var e = Mapper.Map<MyEntityDTO, MyEntity>(edto);
Error:
{"Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\nMyEntityDTO -> MyEntityExample\r\nEcoavantis.Interactive.Service.MyEntityDTO -> Ecoavantis.Interactive.Service.MyEntity\r\n\r\nDestination path:\r\nMyEntity\r\n\r\nSource value:\r\nEcoavantis.Interactive.Service.MyEntityDTO"}