Is there any tool to generate DTOs from entities?
I want to generate DTOs from entities in a totally automated way. By th开发者_JS百科at I mean some tool reading my .edmx model and converting it to DTO's. I've seen this in stackoverflow but that is a superficial level of automation. I do not want to write too much code... if possible not to write any code at all.
Normally, the Entity Framework generates C# entity types for your model using an internal templating system. In Entity Framework 4, you can replace this with a custom T4 template. In addition to emitting the entity types, you could change the template to admit DTOs at the same time.
Right-click the model designer surface. Click "Add Code Generation Item." Customize the emitted T4 template.
精彩评论