Asp – NULL ForeignKeyTo property in Subsonic 3/ASP.NET MVC

asp.net-mvcsubsonicsubsonic-v3p2subsonic3

Issue: the primary key of the base table is named differently than the the key in the fk table.

Subsonic 3 does not know how to handle that, which is fine, its beta. So I was going to change the Html.ControlFor logic to just grab the table and use the pkname from that:

var fk = db.FindTable(col.ForeignKeyTo.FriendlyName);

However the .ForeignKeyTo is null. Where in the templates does that ITable get populated?

Best Answer

It shouldn't matter at all if the FK is named differently - what SubSonic looks for is a FK relationship - an actual CONSTRAINT in the DB. But the code you show above looks like it comes from a spike I did a long time ago - are you using 3.0.0.3?

We've been out of beta for a long time :) http://subsonicproject.com