0

I'm trying to scaffold an existing database using the LinqToDB templates. All of the tables in the database have a prefix of "tbl", i.e "tblPerson". I would like to strip this (and other prefixes) from my type names. I tried modifying the DataModel.ttinclude file in the LinqToDB.Templates directory but it doesn't seem to have any affect.

TypeName = t.TypeName.StartsWith("Tbl") ? t.TypeName.Replace("Tbl","") : t.TypeName,

Clearly I'm missing something simple.

Paul B
  • 11
  • 1
  • 1
    Check customization section to see how to modify generation model https://linq2db.github.io/articles/T4.html#example-of-generation-process-customization –  May 14 '20 at 08:29
  • Thanks, that helped! – Paul B May 15 '20 at 16:25

1 Answers1

0

Thanks to the link from DLuk, I was able to modify the tables using the following code in my DB.tt file.

foreach (var t in Tables.Values)
{
    t.TypeName = t.TypeName.StartsWith("Tbl") ? t.TypeName.Replace("Tbl","") : t.TypeName;
    t.DataContextPropertyName = t.TypeName;
    foreach(var k in t.ForeignKeys.Values)
    {
        k.MemberName = k.MemberName.StartsWith("Tbl") ? k.MemberName.Replace("Tbl","") : k.MemberName;
    }
}
GenerateModel();
Paul B
  • 11
  • 1