Skip to content

Commit

Permalink
More #21 for primary/foreign/composite columns
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjw authored Dec 14, 2016
1 parent dc10a63 commit 36317b0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DatabaseSchemaReader/CodeGen/ClassWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ internal static string PropertyName(DatabaseColumn column)
}
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 propertyName + "Id";
}
//a foreign key will be written, so we need to avoid a collision
var refTable = FindForeignKeyTable(column);
var fkDataType = refTable != null ? refTable.NetName : column.ForeignKeyTableName;
Expand Down

0 comments on commit 36317b0

Please sign in to comment.