EntityPropMappings.tt

EntityPropMappings.Dict is attached into the constructor when creating D3Context. 

1. Update the input arguments


PropKeyRegex = new Regex(@"[A-Za-z_][A-Za-z0-9_]+Id$");
PropIdFormat = "{0}Id";
DbIdFormat = "{0}_id";
NameSpaceStr = "KLO128.D3ORM.Sample.Infra.D3ORM.MySQL";
EntitiesNameSpace = "KLO128.D3ORM.Sample.Domain.Models.Entities";
var sourceProjectFile = Host.ResolvePath("../KLO128.D3ORM.Sample.Domain/IQueryContainer.cs"); //any root file
Input arguments are defined in the first 5 lines. PropIdFormat and DbIdFormat let you use different name conventions for id columns (properties). Other column names are derived from property names using database specific name rules. Navigation properties of any collection type should be named in plural form, but it is not required. 

  • PropKeyRegex is a regular expression used for recognition of id properties. 
  • PropIdFormat is the id property name format. 
  • DbIdFormat is the id column name format. 
  • NameSpaceStr is the namespace of the generated (target) class. 
  • EntitiesNameSpace is the namespace of entities. 
  • sourceProjectFile is the path of some root project file, where the entities are located in. 

2. Run the text template

Run the text template to generate the core entity navigation and the core mappings between application and database names.