For example, renaming all primary properties to the name 'Id'. Is this possible? When I try for example something like this I get an exception
Code: Select all
Code: Select all
If you want to generate the file with the list of your entity classes names with added "SomeSuffix", please use this code:delarou wrote:When I try for example something like this I get an exception
Code: Select all
    
You should create your own template by modifying our predifined template: navigate to the Tools > Entity Developer > Model Explorer menu of Visual Studio, right click on the predefined template > Copy to Model Folder, and make these changes:delarou wrote:For example, renaming all primary properties to the name 'Id'. Is this possible?
Code: Select all
EntityDeveloper.Mapping.IDbColumn column = GetColumnByName(cls, "DATUM_CREATIE"); 
EntityDeveloper.Mapping.ColumnMapping columnMapping = new EntityDeveloper.Mapping.ColumnMapping(column, dateCreationProperty);
  cls.ClassMapping.TableMappings[0].ColumnMappings.Add(columnMapping);

Code: Select all
 c.Name == "Class1");
      Property newParentProperty = model.CreateNewProperty();
      newParentProperty.Name = "MyParentProperty";
      newParentProperty.Type = destComplexType;
      sourceClass.AddProperty(newParentProperty);
      foreach (Property baseProperty in sourceClass.Properties.Where(p => p.Name == "Property2" || p.Name == "Property3").ToList()) {
        Property destProperty = baseProperty.Clone() as Property;
        destProperty.ParentClass = destComplexType;
        destProperty.Name = baseProperty.Name;
        destComplexType.AddProperty(destProperty);
        foreach (EntityDeveloper.EntityFramework.Mapping.EntityTableMapping tableMap in sourceClass.ClassMapping.TableMappings) {
         for (int i = tableMap.ColumnMappings.Count - 1; i >= 0; i--)
            if (tableMap.ColumnMappings[i].Property == baseProperty) {
              EntityDeveloper.Mapping.ColumnMapping m = new EntityDeveloper.Mapping.ColumnMapping(tableMap.ColumnMappings[i].Column, destProperty);
              foreach (Property p in tableMap.ColumnMappings[i].ParentProperties)
                m.ParentProperties.Add(p);
              m.ParentProperties.Add(newParentProperty);
              tableMap.ColumnMappings.Remove(tableMap.ColumnMappings[i]);
              tableMap.ColumnMappings.Add(m);
            }
       sourceClass.RemoveProperty(baseProperty);
         }
       }
  #>