Error: Missing type map configuration or unsupported mapping
□ Background
When saving the View Model into Domain Model, an error occurred in AutoMapper.
□ Analysis
1. A mapping has been established in the Profile class derived from AutoMapper:
Mapper.CreateMap<SomeDomainModel, SomeViewModel>();
2. The classes derived from Profile have also been initialized:
public static class AutoMapperConfiguration { public static void Configure() { Mapper.Initialize(x => x.AddProfile<SomeProfile>()); } }
3. Also registered in the global:
protected void Application_Start() { //Configuration mapping AutoMapperConfiguration.Configure(); }
4. The unit test also passed:
[TestClass] public class AutoMapperConfigurationTester { [TestMethod] public void TestMethod1() { AutoMapperConfiguration.Configure(); Mapper.AssertConfigurationIsValid(); } }
□ Solution
When actually mapping, replace AutoMapper.Mapper.Map<Source, Destination> with AutoMapper.Mapper.DynamicMap<Source, Destination>
DomainModel someDomainModel = AutoMapper.Mapper.Map<ViewModel, DomainModel>(someViewModel);
Change to:
DomainModel someDomainModel = AutoMapper.Mapper.DynamicMap<ViewModel, DomainModel>(someViewModel);
Read More:
- How to Solve Go Error: concurrent map iteration and map write
- OpenCV(-206:Bad flag (parameter or structure field)) Unrecognized or unsupported array type [How to Solve]
- How to Solve Error: IncompleteElementException: Could not find result map…
- How to Solve Error: Unsupported field: HourOfDay
- Abnormal [System.InvalidOperationException: custom type mapping for ‘xxx’ is not specified or is not a solution
- ElasticSearch Create Index Error: mapper_parsing_exception Root mapping definition has unsupported parameters
- [Solved] The method getContextPath() from the type HttpServletRequest refers to the missing type String
- How to Solve Cordova integrates Gaode Map key error
- How to Solve Error: Type mismatch: cannot convert from Object to Car
- [Go] Solve the fatal error: concurrent map writes map is not concurrently safe
- How to Solve Error: Element ‘dependency’ cannot have character [children], because the type’s content type is element-
- How to Solve Error Swift 4 Expression type ‘@value CGRect’ is ambiguous without more context
- How to Solve Springboot Error: Failed to convert value of type
- How to Solve NPM run dev error: missing script:dev
- How to Solve Hadoop Missing Hadoop.dll and winutils.exe file error
- [Solved] Postman Error: Unsupported Media Type
- How to Solve TypeError: type numpy.ndarray doesn’t define __round__ method
- How to Solve TypeError: type numpy.ndarray doesn‘t define __round__ method
- How to Solve mount error(6): No such device or address