I'm using automapper to map values from one object to another and then saving the object to a db using ef6. I would like Automapper to ignore any null values in the base so that the EF doesn't overwrite the original stored value with null. I've tried the below code but it seems the properties are set as null as the values are removed when stored in the db.
Any ideas?
cfg.CreateMap<BidBase, ProjectBase>()
.ForMember(dest => dest.RambollProjectStartDate, opt => opt.MapFrom(src => src.ExpectedProjectStartDate))
.ForAllMembers(opt => opt.Condition((source, destination, sourceMember) => sourceMember != null));
Update
I've realised that the problem is because automapper sets the properties of the destination object to null if they do not exist in the source object. This means that the value in the db is being set to null by the EF. How can I handle this?