AutoMapper with dynamic type: Missing type map configuration or unsupported mapping
<p>Answer: <code>CreateMissingTypeMaps</code> must be set to <code>true</code> to make dynamic mapping working.</p>

<pre><code>    public IEnumerable&lt;T&gt; GetDummies&lt;T&gt;(IEnumerable&lt;dynamic&gt; dummies)
    {
        var config =
            new MapperConfiguration(c =&gt; { c.CreateMissingTypeMaps = true; });

        IMapper mapper = config.CreateMapper();
        return dummies.Select(mapper.Map&lt;T&gt;).ToList();
    }
</code></pre>

<hr>

<p>I have wrapper around Entity Framework to perform queries to database. I want to allow user to select only required properties, but keep result of entity type.</p>

<p>This is dummy code (without using EF, but having same issue)</p>

<pre><code>class Program
{
    static void Main(string[] args)
    {
        var dummies = new[]
        {
            new DummyContainer
            {
                Name = "First",
                Description = "First dummy",
                DummyNumbers = new List&lt;int&gt; { 1, 2, 3 },
                Foo = new FooThingy { Title = "Foo thingy" }
            }
        };

        var smallDummies = dummies.Select(d =&gt; new { d.Name }).ToList();
        List&lt;DummyContainer&gt; fullDummies = smallDummies.Select(Mapper.Map&lt;DummyContainer&gt;).ToList();

        Debugger.Break();
    }
}

class DummyContainer
{
    public string Name { get; set; }
    public string Description { get; set; }
    public ICollection&lt;int&gt; DummyNumbers { get; set; }
    public FooThingy Foo { get; set; }
}

class FooThingy
{
    public string Title { get; set; }
}
</code></pre>

<p>Getting this exception:</p>

<pre><code>Missing type map configuration or unsupported mapping.

Mapping types:
&lt;&gt;f__AnonymousType0`1 -&gt; DummyContainer
&lt;&gt;f__AnonymousType0`1[[System.String, mscorlib, Version=4.0.0.0,  Culture=neutral, PublicKeyToken=b77a5c561934e089]] -&gt; AutoMapperWithGenerics.DummyContainer

Destination path:
DummyContainer

Source value:
{ Name = First }
</code></pre>

<p>I'm bit stuck here, because documentation states that AutoMapper uses property names to map back to object: <a href="https://github.com/AutoMapper/AutoMapper/wiki/Dynamic-and-ExpandoObject-Mapping" rel="nofollow">Dynamic and ExpandoObject Mapping</a>.</p>

<p>Please note that code above is example. In my application, things get bit crazy as I'm actually using generics, e.g.</p>

<pre><code>Mapper.Map&lt;TEntity&gt;
</code></pre>

<p>... and it should stay this way - I don't know what entity type is used. My expectation is just: map properties to existing type, if missing, set <code>default(T)</code>.</p>

<hr>

<p>Edit: I tried to specify mapper from <code>dynamic</code> to <code>T</code>, almost full code here:</p>

<pre><code>class Program
{
    static void Main(string[] args)
    {
        // ...

        var dumminator = new DummyService();
        IEnumerable&lt;DummyContainer&gt; bigDummies = dumminator.GetDummies&lt;DummyContainer&gt;(smallDummies);

        Debugger.Break();
    }
}

class DummyService
{
    public IEnumerable&lt;T&gt; GetDummies&lt;T&gt;(IEnumerable&lt;dynamic&gt; dummies)
    {
        var config = new MapperConfiguration(c =&gt; c.CreateMap&lt;dynamic, T&gt;());
        IMapper mapper = config.CreateMapper();

        return dummies.Select(mapper.Map&lt;T&gt;).ToList();
    }
}
</code></pre>

<p>... this won't die on exception, however result is desperately empty (all properties have <code>default</code> value.</p>