Thanks Walaa for your help.
I now have another little question.
What I really want is generate a public method for each property of the entity which has a default value and I have been able to do it with the following source code but I use the Custom_EntityInitializationTemplate template ID so it generates the method in the InitClassEmpty method.
The question is : How can I generate this method directly in the entity itself?
I tried the Custom_EntityAdapterTemplate (I'm in adapter mode) but no more method is generated in this case.
Thanks in advance.
// 1) Get the entity mapping
<%EntityDefinition entity = ((Hashtable) _activeObject)["CurrentEntity"] as EntityDefinition;
var entityMapping = _executingGenerator.ProjectDefinition.GetGroupableModelElementMapping(entity, _executingGenerator.DriverID);
// 2) For each field, get the associated mapping
foreach(FieldElement fieldElement in entity.Fields)
{
if (fieldElement.Name != "LastChange" && fieldElement.Name != "IsActiveRecord")
{
FieldMapping fieldMapping = entityMapping.GetFieldMappingOfField(fieldElement);
// 3) If the column has a default value, create a GetDefaultXXXXValue() method
if (fieldMapping.MappedTarget.HasDefaultValue)
{%>
public <%=fieldMapping.MappedTarget.NETTypeAsString%> GetDefault<%=fieldElement.Name%>Value()
{
// 4) Need to manage string differently because it needs some "" around
<%if (fieldMapping.MappedTarget.NETTypeAsString == "string")
{%>
return "<%=fieldMapping.MappedTarget.DefaultValue%>";
<%}
else
{%>
return <%=fieldMapping.MappedTarget.DefaultValue%>;
<%}%>
}
<%}
}
}%>