Skip to content

Commit

Permalink
More #21 Naming for primarykeys/fks/composites
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjw authored Dec 14, 2016
1 parent 36317b0 commit b184b5f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DatabaseSchemaReader/CodeGen/Namer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public virtual string PrimaryKeyName(DatabaseColumn column)
var primaryKeyName = column.NetName;
if (column.IsPrimaryKey && column.IsForeignKey)
{
//if it's a composite key as well, always write an Id version
var table = column.Table;
if (table != null && table.HasCompositeKey)
{
return primaryKeyName + "Id";
}
//a foreign key will be written, so we need to avoid a collision
var refTable = column.ForeignKeyTable;
var fkDataType = refTable != null ? refTable.NetName : column.ForeignKeyTableName;
Expand Down

0 comments on commit b184b5f

Please sign in to comment.