Posts Tagged ‘rant’

AutoMapper does not play well with multi tier architecture

September 27th, 2016

I have found out that Automapper needs to be set up once and only once.
This means that one place has to know of all the classes that have a mapping. In a multi tier application this is not possible without treading on someone’s toes.

I have seen a solution which loops through all loaded assemblies and maps once and for all. But this solution means we have one such point – like when a web app is loading. So if you have automatic tests, that setup has to be called from there. And any kind of automatic loading of assemblies cannot use Automapper. Well… if one reinitialises all mappings one can.

I might see another solution where one has one assembly that knows of all assemblies (with mapping) and makes sure Automapper is initialised. My experimentation with this lead to circular reference problem though.

When I am at it – the documentation is short and straight to the point (good) but misses the point that the code in the documentation should be usable (not good).

The API was not explorable, which means that there is no natural way to start mapping and find out how the API works as one goes. Instead I had to google and find a bit here and a bit there.

With that said – it still solved a problem for me. And that is considered good.