JPCF
JPCF

Reputation: 2271

Is there any tool to generate DTOs from entities?

I want to generate DTOs from entities in a totally automated way. By that 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.

Upvotes: 6

Views: 1605

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126587

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.

Upvotes: 2

Related Questions