I'm trying to configure a simple AutoMapper mapping from an Entity Framework entity to a view model object. It mostly works but in the view model I have an int field to hold a count. This field does not exist in the source entity.
.ForMember(dest => dest.Count, opt => opt.MapFrom(src => src.Orders.Count()));
The following property on Feed cannot be mapped:
Add a custom mapping expression, ignore, add a custom resolver, or modify the destination type Feed.
Mapping from type FeedVM to Feed
You should use
cfg.CreateMap<Feed, FeedVM>() .ForMember(dest => dest.Count, opt => opt.ResolveUsing(src => src.Orders.Count()));
John indicates in the comment below that the mappings are correct, the problem lies in a mapping for another entity that is related to
Feed. In that entity he is mapping both directions.