Auto generating DataContract classes from Business Object Classes

This is a good question. I'm actually going to be doing something similar to it in a project I am working on.

I would suggest that there are really two problems here: the first is to generate DTO code from your business objects, and the second is to do the mapping between business object and DTO.

I could not find a code generator for this purpose after spending about a half hour on Google. Perhaps I'm not searching for the right thing, or possibly there isn't one out there (so if someone knows of one, please chime in). The only tool I found that looks promising is NHydrate (http://www.codeproject.com/Articles/42885/NHydrate-Code-Generator), but I did not actually download it or test it.

A mapping tool that I've used in the past is AutoMapper (https://github.com/AutoMapper/AutoMapper/wiki/Getting-started) - it will attempt to figure out the relationship between your business objects and DTOs, and will be able to do two-way mapping.