5 thoughts on “Why Automapping is bad for you

  1. Yeah, I also prefer the “methods” method.

    Currently working on a big project where automapper is used because the tech lead is convinced it’s helping save code-writing time.

    But: to minimise the effort of setting up the mapping, it generally means the entities are field-to-field copied as dto’s, and then copied field-to-field as viewmodels. So all the data is moved, all the time. And this is in a project replacing a previous failed project where one of the faults was entities exposed right up into views, where the main problem was that minor database changes meant breaking UI’s. With all the fields copied one-to-one we get the same problem again … change a field in an entity and you either have to adjust both the dto and viewmodel, or do arcane automapper configuration. What’s improved?

    And: like most frameworks, automapper makes some stuff easy and some stuff hard. I’m not sure the “easy” outweighs the “hard”. One of our best devs had to spend a couple of days getting the automapper configuration correct when a smallish change was made to the storage of a set of entities that shared the same base class; and I doubt anyone else in the project really understands it. I dislike the cognitive load of these frameworks; you need to know C# (or whatever) and also all the domain specific languages (or just configuration) of all of the the little helpers you’ve stuck in your project. I think we now have more automapper configuration code than service layer code.

    I’d much rather just write mapping routines as described in this blog post. Yes, tedious, but hardly worse than having to copy sets of entity properties into dto’s and viewmodels; and it would help encourage paring down the various classes to just what’s needed, e.g. Viewmodels that only contain the data actually needed to view, and be much more understandable to future maintenance devs.


  2. Pingback: Pitfalls of AutoMapper - Gigi Labs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s