Hi,
From Model First design, I am generating c# code using DTO template. The DTOs.cs has all classes except for EnumTypes. I can see them on edml. Other templates (like DBContext) are generating enums also. Does DTO template not support enum generation OR am I missing any template properties settings?
Thanks.
Entity framework - DTO template - Enum type support
Re: Entity framework - DTO template - Enum type support
This is an expected behaviour.Hari wrote:From Model First design, I am generating c# code using DTO template. The DTOs.cs has all classes except for EnumTypes.
The "Data Transfer Object" template is not the main, this is the auxiliary one. Thus, it doesn't generate main objects, including enums. We recommend you to add the DbContext template to your model, too. In this case, the DbContext class, entity classes and enums will be generated.
Re: Entity framework - DTO template - Enum type support
I'm unclear by what you mean by 'auxiliary' vs. 'main'. Can you clarify the intent of the DTO template?
Re: Entity framework - DTO template - Enum type support
There are several templates for code generation available in Entity Developer. These templates are divided into groups:
- Data Access Level
- Domain Level
- Presentation Level
- Shared
Auxiliary means, that the DTO template is usualy used in addition to one of the general templates - DbContext, ObjectContext, POCO Entities, etc., which are made for Data Access Level. The DTO template doesn't generated Context class, entity classes, enums, etc.
This template generates both DTO classes and converter classes with extension methods for converting entities to DTO and vice versa. These converter classes are partial classes with partial methods that you can use to customize the conversion process. If generated converter classes are not suitable for you, you can disable their generation with the Generate Converters property and use some third-party library, for example, AutoMapper, to convert objects.
While the DbContext, or EntityObject, template generates strongly-typed DbContext (or ObjectContext) class and persistence ignorant entity classes, enum types, methods.
Please refer to the corresponding sections in the Entity Developer documentation:
- Template System Concepts
- ORM Support-> Entity Framework-> Concepts-> Model Generation Templates
JIC: Entity Developer documenatation is available with the installation package (the "Help" component should have been selected when installing).
- Data Access Level
- Domain Level
- Presentation Level
- Shared
Auxiliary means, that the DTO template is usualy used in addition to one of the general templates - DbContext, ObjectContext, POCO Entities, etc., which are made for Data Access Level. The DTO template doesn't generated Context class, entity classes, enums, etc.
This template generates both DTO classes and converter classes with extension methods for converting entities to DTO and vice versa. These converter classes are partial classes with partial methods that you can use to customize the conversion process. If generated converter classes are not suitable for you, you can disable their generation with the Generate Converters property and use some third-party library, for example, AutoMapper, to convert objects.
While the DbContext, or EntityObject, template generates strongly-typed DbContext (or ObjectContext) class and persistence ignorant entity classes, enum types, methods.
Please refer to the corresponding sections in the Entity Developer documentation:
- Template System Concepts
- ORM Support-> Entity Framework-> Concepts-> Model Generation Templates
JIC: Entity Developer documenatation is available with the installation package (the "Help" component should have been selected when installing).
Re: Entity framework - DTO template - Enum type support
Thank you for clarifying that. Appreciated.