1

In my Global.asax:

        AutoMapper.Mapper.CreateMap<ViewModel, DataType>()
            .ForMember(dest => dest.User, opt => opt.Ignore());

In my MVC Action:

        AutoMapper.Mapper.Map(viewmodel, data);

Prior to calling the Map() function, data.User is not null. Immediately after calling Map(), data.User is now null, however, if I am understanding correctly, Ignore() should completely ignore that property and leave it untouched. Any ideas as to what might be causing this?

Keith
  • 5,311
  • 3
  • 34
  • 50

1 Answers1

1

I clearly didn't give enough information for anyone to solve this.

My problem happened to occur because my data model is an EF4 Entity, and my View Model had a mapping to a Foreign Key that was mapped to the User object mentioned above. Once we call Map(), it reset the User entity to null. Once I removed this property from my ViewModel, everything began working as expected.

Keith
  • 5,311
  • 3
  • 34
  • 50