Skip to content

You have multiple concrete types mapped with the same named registration

Isaac Abraham edited this page Jan 26, 2016 · 6 revisions

###Scenario Unity will simply overwrite named registrations with the latest one it gets (kind of a "last past the post" behaviour). To prevent accidentally missing mappings, if the Automapper finds two mappings for the same interface with the same name, it throws an exception. ###Example

public interface IMyService { }
[MapAs("Foo")] public class MyService : IMyService { }
[MapAs("Foo")] public class MyOtherService : IMyService { } // "Foo" is duplicated.

###How do I fix this?

  1. Change the explicit named mapping to something else.
  2. Use the implicit MultimapByDefault behaviour, which will automatically generate registration names based on the concrete type being mapped.