AutoMapper 5.0 Released

Release notes:

Today I pushed out AutoMapper 5.0.1, the culmination of about 9 months of work from myself and many others to build a better, faster AutoMapper. Technically I pushed out a 5.0.0 package last week, but it turns out that almost nobody really pulls down beta packages to submit bugs so this package fixes the bugs reported from the 5.0.0 drop :)

The last 4.x release introduced an instance-based configuration model for AutoMapper, and with 5.0, we’re able to take advantage of that model to focus on speed. So how much faster? In our benchmarks, 20-50x faster. Compared to hand-rolled mappings, we’re still around 8-10x slower, mostly because we’re taking care of null references, providing diagnostics, good exception messages and more.

To get there, we’ve converted the runtime mappings to a single compiled expression, making it as blazing fast as we can. There’s still some micro-optimizations possible, which we’ll look at for the next dot release, but the gains so far have been substantial. Since compiled expressions give you zero stack trace if there’s a problem, we made sure to preserve all of the great diagnostic/error information to figure out how things went awry.

We’ve also expanded many of the configuration options, and tightened the focus. Originally, AutoMapper would do things like keep track of every single mapped object during mapping, which made mapping insanely slow. Instead, we’re putting the controls back into the developer’s hands of exactly when to use what feature, and our expression builder builds the exact mapping plan based on how you’ve configured your mappings.

This did mean some breaking changes to the API, so to help ease the transition, I’ve included a 5.0 upgrade guide in the wiki.


About Jimmy Bogard

I'm a technical architect with Headspring in Austin, TX. I focus on DDD, distributed systems, and any other acronym-centric design/architecture/methodology. I created AutoMapper and am a co-author of the ASP.NET MVC in Action books.
This entry was posted in AutoMapper. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Cool! Thanks for the guide, I was looking for it. Please also include the change for DI containers integration, seems it has been changed too.

  • Calvin Craig

    Attempted to “dotnet restore” the “samplesangularMusicStore” project.
    Got “Unable to resolve ‘AutoMapper (>= 4.1.1)’ for ‘.NETCoreApp,Version=v1.0′.”
    Changed “4.1.1″ seting in project.json to “AutoMapper”: “5.0.1″.
    Got “Unable to resolve ‘AutoMapper (>= 5.0.1)’ for ‘.NETCoreApp,Version=v1.0′.”
    Any ideas? Thanks!

    • jbogard

      Maybe upgrade your NuGet?

  • Dave

    With regards to circular references, does calling PreserveReferences effectively use the same behaviour as v.4?

    And I am guessing you can combine that call with a call to max depth in a fluent manner i.e. CreateMap<DoorKnob,DoorKnobDto>().PreserveReferences().MaxDepth(3);

    Is that correct? (Thanks for progressing this awesome project.)

    • jbogard

      Yeah, PreserveReferences does. It was terribly expensive to do it for *all* maps, so now it’s opt-in. And yes, you can combine them, but typically people don’t, they use one or the other. MaxDepth works well if the reference checking doesn’t work for some reason. Or if you have a hierarchy instead of just circular references.

      • Dave

        Thanks Jimmy. I like the “opt in” approach you have taken. Be well.