I have a reference table with all sorts of controlled value lookup data for gender, address type, contact type, etc. Many tables have multiple foreign keys to this reference tab
So I went down the partial classes route. For instance, I added the following member to address the first reference member in my original example:
public partial class tb_account
{
public tb_reference shipping_preference_reference
{
get
{
return this._tb_reference.Entity;
}
set
{
this.tb_reference = value;
}
}
This is far from perfect. It requires a substantial amount of extra code in a large model, and depends on the order of the attributes to not change (if another foreign key to the reference table is added to the account table, this member may actually point to something else than the shipping preference). There is an upside, too. Since I am already writing partial classes for other purposes, adding these members did not require that I rearchitect the application.