Hello,
I am using the Linq To SQL templates and I am generating a class for a table called PackageCode. PackageCode has a one-to-one relationship with another table called SchemeConfig. PackageCode has a primary key called PackageId which is also a foreign key in the relation with SchemeConfig. The primary key in SchemeConfig is called SchemeID.
The problem is with the content of the association attribute generated in the PackageCode class for the property mapping to the SchemeConfig table. It is looking like this:
[Association(Name="SchemeConfigTable_PackageCodeTablePackageId", Storage="_SchemeConfigTable", ThisKey="PackageId", IsForeignKey=true, OtherKey="PackageId")]
public SchemeConfigTable SchemeConfigTable
{
The OtherKey property value is not correct as it should be SchemeID. After looking at the linqToSqlEntity.lpt template file it would appear that if the relationship used to generate this property does not have the primary key on the start entity side, it will use the same keys for both the ThisKey and OtherKey values. This is because:
ThisKey="<%=SD_LinqToSqlGeneralUtils.GetKeyNames(relation, relation.StartEntityIsPkSide)%>
and
OtherKey="<%=SD_LinqToSqlGeneralUtils.GetKeyNames(relation, false)%>
both call SD_LinqToSqlGeneralUtils.GetKeyNames with the same parameters.
If you can suggest a modification to make to the linqToSqlEntity.lpt template that resolves this problem that would be great. There also has been modifications made already to this template, so it is not the out of the box linqToSqlEntity.lpt. It has been changed to name the Linq entity classes with a Table suffix.