0

I've tried to scaffold an existing database using the t4 file as described here

Now I've found that the relation I've have really ugly looking naming,consider this case

/// <summary>
    /// FK_XX_CONVENZIONI_XX_COMPAGNIE_BackReference
    /// </summary>
    [Association(ThisKey="IdCompagnia", OtherKey="IdCompagnia", CanBeNull=true, Relationship=Relationship.OneToMany, IsBackReference=true)]
    public IEnumerable<BenefitConvenzioni> XXCONVENZIONIXXCOMPAGNIEs { get; set; }

I've tried as suggested to put

 GetSchemaOptions.GetAssociationMemberName = key => "Association_" + key.MemberName; 

But it doesn't change the behavior... any suggestion?

yole
  • 92,896
  • 20
  • 260
  • 197
advapi
  • 3,661
  • 4
  • 38
  • 73

1 Answers1

1

You have to put this code before LoadMetadata

GetSchemaOptions.GetAssociationMemberName = key => "Association_" + key.MemberName; 

// other tweaks

LoadMetadata(....)

It is also mentioned in documentation Configuring generation process

Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32
  • ok, but is there a way I can tell to leave the references as ```FK_XX_CONVENZIONI_XX_COMPAGNIE_BackReference``` and not ```XXCONVENZIONIXXCOMPAGNIEs ``` – advapi Nov 13 '18 at 14:07
  • 1
    Currently there is no way to setup option for that but you can override function `ConvertToCompilable`: `ConvertToCompilable = (name, removeUnderscores) => ConvertToCompilableDefault(name, name.StartsWith("FK_") ? false : removeUnderscores);` – Svyatoslav Danyliv Nov 13 '18 at 14:47