Automapper returns empty Collection after mapping

Some days ago I had a problem while mapping domain objects to DTO by automapper. My environment was an Asp.Net Core 3 Web Api project. I created an own profiles class where I stored my mapping logic. In the startup class I registered the mapper service. When running project my source of type List<Product> should be mapped to List<ProductDTO>. But the API always returned an empty list even if the source was filled correctly.

Profile:


CreateMap<Product, ProductDTO>();

CreateMap<List<Product>, List<ProductDTO>>();

The mistake was the second line in my profile class. Automapper automatically maps collections you don’t have to create a map for this case.

Publish problem after updating net core version

Updating my dot net core mvc project from version 2.2 to 3.0 I got an error saying „project.assets.json doesn’t have a target for .NETCoreApp,Version=v2.2“. I deleted the mentioned JSON file which was new generated  but nothing changed. After searching for my problem in google I found this link https://github.com/dotnet/sdk/issues/1321 where similiar problems were reported. One of the answers was a good one: Delete your publish profile and try again. This worked for me and I hope for many other people out there getting this error.