Replies: 1 comment 1 reply
-
If you scroll down to the https://docs.automapper.org/en/latest/Getting-started.html#where-do-i-configure-automapper section you can find a link to https://docs.automapper.org/en/latest/Dependency-injection.html#asp-net-core that describe how to configure AM with dependency injection. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Can be found here: https://docs.automapper.org/en/latest/Getting-started.html
In the guide, the following setup example is given:
However, in order to use dependency injection and inject the mapper in the classes where you want to use it, for example with constructor injection, you need to register the mapper with service container and a service lifetime, e.g.:
Removing the line
services.AddSingleton(mapper);
would result in this run-time error:So I am wondering what is the reason, why registering the mapper with the service container is not included in the getting started guide? I am sure, that it is me who misunderstands something, so I would love to hear explanations. Best regards and thanks for an awesome library.
Beta Was this translation helpful? Give feedback.
All reactions