Frist, absolutely a fan of AutoMapper. The other day added AutoMapper 3.2.0 to my ASP.NET MVC project to handle mapping between my EF 6.0 entities and ViewModels. Initially all was fine, created a simple straight mapping from Entity to ViewModel, meaning no
ForSourceMember. Directed a fellow developer to create Mapper Profiles for remaining Entities and ViewModels using the
ForSourceMember to handle mappings not following naming conventions. The next day he lets me know the
ForMember is not working and won’t compile. My initial response, must be using wrong types. A quick code review, a few cringes and chastings for not using ReSharper I quickly realized that was not the case.
A couple hours before I committed a large refactoring of how EF was leveraged in the application. I was pretty sure my refactoring was not the issue but with any large refactoring there is a possibility. I started playing with the code, ReSharper was yelling at me no matter what I tried until I leveraged the type as a string name.
ReSharper could not poke the expression until I passed the type as a string without using an expression. This allowed me to rule out my refactoring as an issue and pointed to an issue with AutoMapper. I was flabbergasted! I found AutoMapper Issue 381 upon initial read pointed to R# and Automapper. However, I knew from my scenario this was not the case, in fact seemed to be an AutoMapper issue. After reading AutoMapper Issue 381 in it’s entirety the conclusion was AutoMapper was indeed the source of the issue and a patch release was made to resolve the behavior.
AutoMapper 3.2.1 was released April 25th.