I try to move my project to AutoMapper 9.x but I don't find a solution to update an object read from EF.
The situation is like as describe on this old post Using Automapper to update an existing Entity POCO
The big issue is that: AutoMapper 9.x has removed the static Mapper.Map and you can add the [AutoMap(typeof(x))] attribute but it solve the mapping from EF Class to DTO class.
class MyPoco{
public int Id {get;set;}
}
[AutoMap(typeof(MyPoco))]
public class Customer {
public int Id { get;set; }
}
MYPOCO pocoDesc= dbContext.DD_POCO.SingleOrDefault(m => m.Id == 123);
//Row below not supported
AutoMapper.Mapper.Map<Customer, MYPOCO>(customerSrc, pocoDesc);
dbContext.Save();
At the moment the only way to solve is remove AutoMapper and manually bind one by one the property.
UPDATE
After some test I try to compare to call
ObjectMapper.Map(input.Article, article);
Mapper.Instance.Map(input.Article, article);
ObjectMapper came from DI. In startup module I register via IMapperConfigurationExpression
mapper.CreateMap<Customer,MyPoco>().ConvertUsing((src,dto) =>{
// remove for brevity
});
And I see that static API not pass throw my custom map opposite to ObjectMapper that use my custom map. At the moment I don't understand why but I try to investigate more