I have a REST-style web application that uses EF code first. I'm using AutoMapper to map my classes to DTO classes for passing across the wire, and (hopefully) back.
When I map from my POCO classes to DTOs, I'm actually starting with an EF proxy object, since the objects I'm dealing with were the result of executing some sort of query against my DataContext
. This seems to work fine, however.
When I get back a DTO class as part of a POST request, I can use AutoMapper to map it onto my POCO class, and this works fine too.
However because AutoMapper is just new()-ing the POCO objects rather than using the Create
method on the EntitySet
, I now have a POCO class rather than the corresponding EF proxy class. This makes it harder for me to add the data to my database etc.
How can I persuade AutoMapper to use EntitySet.Create
? Or is there another way to achieve the same result?