EfCore.GenericServices: AutoMapper upgrade to version 9.0.0 results in error: MissingMethodException IgnoreAllPropertiesWithAnInaccessibleSetter()
We are trying to update all packages in our solution to the latest versions. When upgrading AutoMapper to version 9.0.0 to following error occurs:
System.MissingMethodException : Method not found: 'AutoMapper.IMappingExpression`2<System.__Canon,System.__Canon> AutoMapper.IMappingExpression`2.IgnoreAllPropertiesWithAnInaccessibleSetter()'.
at GenericServices.Setup.Internal.CreateConfigGenerator.ConfigGenerator`2.AddSaveMappingToProfile(Profile writeProfile)
at GenericServices.Setup.UnitTestSetup.AddSingleDto[TDto](SpecificUseData utData)
at GenericServices.Setup.UnitTestSetup.SetupSingleDtoAndEntities[TDto](DbContext context, IGenericServicesConfig publicConfig)
The depedencies of GenericServices are: AutoMapper (>= 7.0.1) Microsoft.AspNetCore.JsonPatch (>= 2.1.1) Microsoft.EntityFrameworkCore (>= 2.1.1)
It would be nice that GenericServices is compatible with the latest version of AutoMapper.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (8 by maintainers)
Hmm. I didn’t know that! I’m busy on a contract so I’m not sure when I will get to it, but its now on my list!
Ok, that makes more sense! Thanks.
In reply to @baoduy,
Are you aware on how GenericServices sets up AutoMapper? It builds a separate read/write IMapper from any normal AutoMapper usage so that they don’t get confused. It does this using the standard mapping approach, i.e. not the new
[AutoMap(...)]
approach. See this page in the docs.This means GenericServices won’t use the
[AutoMap(...)]
attribute when setting up the mappings. If you want to change the mappings then you use thePerDtoConfig<TDto, TEntity>
class to alter the mapping. I don’t plan to support the[AutoMap(...)]
attribute as I couldn’t implement the readonly feature on properties.Can you explain why you need
CreateMissingTypeMaps = true;
in EfCore.GenericBizRunner? Do you need nested DTOs that you can’t define?Hi @baoduy and others,
I have just released a new version of EfCore.GenericServices, version 2.1.0-preview001 which uses AutoMapper 9.0.0. The actual code is in the ‘dev’ branch at the moment, but if you confirm its OK I will put it in master and release a version 2.1.0 before I start the NetStandard2.1 version.
Please can you check this works with your system soon, as I plan to release a NetStandard2.0 and NetStandard2.1 version next week.
PS. Version 9 of AutoMapper has a
IgnoreAllPropertiesWithAnInaccessibleSetter
method so I can only assume signature changed and the version 7IgnoreAllPropertiesWithAnInaccessibleSetter
didn’t work with the version 9 AutoMapper.Hi @baoduy,
Fine by me. Do make sure the unit tests are updated/passed.
I will be working on the NET Core 3.0 version next week.
Let me take a look on this hope I could able to give an PR in couple of days.