1

I want to map my model to exactly identical config. But always get this error:

Type Map configuration: Model -> Config

Property: Names ----> System.NullReferenceException : Object reference not set to an instance of an object.

cfg.CreateMap<Model, Config>().ForMember(x => x.Names, opt => opt.UseDestinationValue());

Both of Model and Config have values:

public class Model
{
    public List<string> Names {get;set;}
}

public class Config
{
    public List<string> Names {get;set;}
}

What am I doing wrong?

eocron
  • 6,230
  • 18
  • 46

0 Answers0