diff --git a/DatabaseSchemaReader/CodeGen/ClassWriter.cs b/DatabaseSchemaReader/CodeGen/ClassWriter.cs index 7eaaf2c2..843f535f 100644 --- a/DatabaseSchemaReader/CodeGen/ClassWriter.cs +++ b/DatabaseSchemaReader/CodeGen/ClassWriter.cs @@ -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;