To answer your specific question I will speak more generally about your architecture. The architecture you’ve devised for your project is subtly different from a typical architecture used with DDD. While the way you’ve partitioned responsibilities is typical, in DDD, domain classes aren’t responsible for their own persistence. In fact a mantra of DDD is persistence ignorance. This basically means that domain classes are persistence ignorant – they don’t have a Save
method. Instead, application services (application facade layer in your architecture) coordinate with repositories to reconstitute and persist domain entities.
Next, when implementing repositories, there is usually no need for an explicit DTO between the underlying persistence technology and domain classes. With ORMs such as NHibernate and EF, mappings between domain classes and relational tables are expressed with either mapping classes or XML based configurations. As a result, your domain classes are mapped implicitly – no need for DTO. Some cases do call for a DTO, in which case the mapping between the DTO and domain class should be encapsulated by the repository implementation. This is one place where you could invoke AutoMapper.
Finally, it is a common practice to communicate between the presentation layer and the application/domain layer with DTOs. To determine exactly where the mapping should take place you have to dig deeper into the architecture that is a best fit your your project. Most modern DDD architectures are based on the Hexagonal architecture. In a hexagonal architecture, your domain is at the center and all other “layers” adapt the domain to specific technologies. For instance, a repository can be seen as an adapter between the domain and a specific database technology. ASP.NET WebAPI can be seen as an adapter between the domain and HTTP/REST. Likewise, the presentation layer can be seen as an adapter between the domain and a specific. DTOs can manifest within each of these adapters and it is the adapter’s responsibility to map to and from these DTOs.
A typical example would be to use application services to establish a facade over your domain. No DTOs at play yet. Next, you create a service layer (open host service in DDD) with ASP.NET WebAPI – an adapter. You create ASP.NET WebAPI specific DTOs and it is up to this adapter to map to and from these DTOs. Therefore, if you use AutoMapper, it should be invoked in this layer. This can be done either explicitly or in an aspect-oriented way with action filters. The same holds for the presentation layer. The presentation layer could be coupled directly to application services, or to an ASP.NET WebAPI open host service. In either case, it is the responsibility of the presentation layer to map between domain classes (from application service or DTOs from WebAPI) and its own primitives such as a ViewModel.