Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to solve AutoMapper.AutoMapperConfigurationException? #4367


User avatar
0
manojreddy created

When I'm running this code, I have started getting the below error, It was working fine before upgrading to 2.0.

await InsertAsync(ObjectMapper.Map<Test>(input));


[AutoMap(typeof(Test)]
    public  class TestInput
    {
        public int Id { get; set; }
        public  string TestCode { get; set; }
    }
	
	
[Table("Test")]
public class Test : FullAuditedEntity
{
	[Required]
	[MaxLength(250)]
	public string TestCode { get; set; }
}

AutoMapper.AutoMapperConfigurationException: Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters

TestInput -> Test (Destination member list) MyCompany.MyProject.Business.Dto.Tests.TestInput -> MyCompany.MyProject.Business.Model.Tests.Test (Destination member list)

Unmapped properties: IsDeleted DeleterUserId DeletionTime LastModificationTime LastModifierUserId CreationTime CreatorUserId


8 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team
    1. Is that list of Unmapped properties from the exception?
    2. Are those all of the properties in the entity and input?
  • User Avatar
    0
    banksearch created

    I am having the same issue.

    Why would I need to add these properties in MyTestInput:

    IsDeleted DeleterUserId DeletionTime LastModificationTime LastModifierUserId CreationTime CreatorUserId

    All these properties are automatically filled by the framework. This is not a data that I collect from the end user. So It is pointless to add those into POCO Input class.

    Any better sugestion why this error happens when Input is mapped into actual Entity class?

  • User Avatar
    0
    manojreddy created

    Getting the same error while running Debug Test

    [12/21/2017 2:11:55 PM Informational] ------ Run test started ------ [12/21/2017 2:12:31 PM Informational] [xUnit.net 00:00:21.4148917] Starting: MyCompany.MyProject.Tests [12/21/2017 2:13:00 PM Error] [xUnit.net 00:00:49.7006988] MyCompany.MyProject.Tests.MyEntity.MyEntityAppService_Test.Should_Create_MyEntity_With_Valid_Arguments [FAIL] [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7027177] AutoMapper.AutoMapperConfigurationException : Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters

    [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7030122] MyEntityInput -> MyEntity (Destination member list) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7030618] MyCompany.MyProject.Business.Dto.MyEntitys.MyEntityInput -> MyCompany.MyProject.Business.Model.MyEntitys.MyEntity (Destination member list) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7031223]
    [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7032049] Unmapped properties: [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7032437] IsDeleted [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7032663] DeleterUserId [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7032896] DeletionTime [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7033098] LastModificationTime [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7033324] LastModifierUserId [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7033574] CreationTime [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7033838] CreatorUserId [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7034054]
    [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7044987] Stack Trace: [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7055490] at lambda_method(Closure , MyEntityInput , MyEntity , ResolutionContext ) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7056192] at lambda_method(Closure , Object , Object , ResolutionContext ) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7057142] C:\Users\MyName\source\repos\MyProject\aspnet-core\src\MyCompany.MyProject.Business.Data\Repositories\MyEntityRepository.cs(429,0): at MyCompany.MyProject.Business.Repositories.Repositories.MyEntityRepository.<CreateMyEntityLevelCategory>d__25.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7057588] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7057947] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7058296] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7058716] C:\Users\MyName\source\repos\MyProject\aspnet-core\src\MyCompany.MyProject.Business.Data\Repositories\MyEntityRepository.cs(373,0): at MyCompany.MyProject.Business.Repositories.Repositories.MyEntityRepository.<CreateMyEntityManually>d__23.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7059062] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7059344] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7059778] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7060600] C:\Users\MyName\source\repos\MyProject\aspnet-core\src\MyCompany.MyProject.Business.Data\Repositories\MyEntityRepository.cs(70,0): at MyCompany.MyProject.Business.Repositories.Repositories.MyEntityRepository.<CreateMyEntity>d__12.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7061071] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7061451] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7061823] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7062201] D:\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs(40,0): at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinally>d__1.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7062522] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7062819] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7063145] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7063465] at MyCompany.MyProject.Business.Services.MyEntitys.MyEntityAppService.<CreateMyEntity>d__4.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7063732] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7064009] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7064478] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7065476] D:\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs(40,0): at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinally>d__1.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7065989] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7066320] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7066669] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7067054] D:\Github\aspnetboilerplate\src\Abp\Threading\InternalAsyncHelper.cs(20,0): at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithFinally>d__0.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7067377] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7067694] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7068003] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7068393] C:\Users\MyName\source\repos\MyProject\aspnet-core\test\MyCompany.MyProject.Tests\MyEntity\MyEntityappservice_test.cs(20,0): at MyCompany.MyProject.Tests.MyEntity.MyEntityAppService_Test.<Should_Create_MyEntity_With_Valid_Arguments>d__1.MoveNext() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7068687] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7068970] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7069297] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7069548] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7069837] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7070170] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7070408] --- End of stack trace from previous location where exception was thrown --- [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7070764] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7071072] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [12/21/2017 2:13:00 PM Informational] [xUnit.net 00:00:49.7272042] Finished: MyCompany.MyProject.Tests [12/21/2017 2:13:00 PM Informational] ========== Run test finished: 1 run (0:01:04.7057513) ==========

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ManojReddy,

    Do you have inherited entities which are used in this test ?

  • User Avatar
    0
    manojreddy created

    I didn't get your question, Could you please explain it clearly?

    Do you have inherited entities which are used in this test ?

  • User Avatar
    0
    ismcagdas created
    Support Team

    I mean something like this:

    public class User : Entity
    {
         ...
    }
    
    public class Manager : User
    {
        ....
    }
    
  • User Avatar
    0
    AceNetZero18 created

    Did anybody solve this issue? An unhandled exception occurred while processing the request. Unmapped members were found. Review the types and members below. ..... No available constructor.

  • User Avatar
    0
    aaron created
    Support Team

    Show your entity and how you configured the mapping.