question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Startup.cs(36,22): error CS1061: 'IServiceCollection' does not contain a definition for 'AddAutoMapper' and no accessible extension method 'AddAutoMapper' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)

Resolved by placing using Automapper; at the top of Startup.cs file

See https://stackoverflow.com/questions/42916182/trying-to-add-automapper-to-netcore1-1-not-recognising-services-addautomapper

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

18reactions
eric-wilsoncommented, Oct 26, 2020

@subhanisyed17 - I had the same problem until I added AutoMapper.Extensions.Microsoft.DependencyInjection Nuget package.

https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/

1reaction
fmjnaxcommented, Jan 3, 2022

If you are having issue with adding your auto mapper, It is better you check through the type and version you added. If it is not “AutoMapper.Extensions.Microsoft.DependencyInjection”, then you won’t be able to use “services.AddAutoMapper()”. Sometimes, you might mistakenly add "AutoMapper

@Sunboy005 Thanks! This was the trick for me in my Blazor WASM project. I had both AutoMapper and AutoMapper.Extensions.Microsoft.DependencyInjection. I removed the AutoMapper package and everything worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · AutoMapper/AutoMapper
A convention-based object-object mapper in .NET. . Contribute to AutoMapper/AutoMapper development by creating an account on GitHub.
Read more >
Is using automapper bad? : r/csharp
I use Mapster and do not use AutoMapper. Same problem poster above alludes to exists with both - it creates runtime-only dependencies. Much...
Read more >
c# - .Net Core Automapper: Problems with Mapping
I am getting an error using Automapper. When I call map I am getting an error. It is explained in the next classes:...
Read more >
AutoMapper considered harmful | anthonysteele.github.io
But these are side issues to the main objections. Mapping code is not worth abstracting. If your AutoMapper mappings are trivial, why not...
Read more >
AutoMapper considered harmful
AutoMapper considered harmful · Poor code navigation experience · Refactoring issues · Domain Driven Development · Mapping validation · To summarize.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found