Closed Mattnificent closed 3 years ago
Oh, I just realized a workaround is to add the foreign key property in the custom partial class. This is a satisfactory workaround. Still curious though if whether foreign keys are EF shadow properties is a planned feature, not on the roadmap, etc.
@Mattnificent - the design goal is object modeling, and foreign key properties are a byproduct of persistence leaking into reality. An ideal, clean model would hide all persistence details, but I realize that ideal isn't completely achievable. So database details (table name, join table name, foreign key property, etc.) are able to be added to the model if the user sees the need. But automatically adding foreign key properties to the model when an association is created isn't on the roadmap; it would go contrary to the spirit of the tool.
@msawczyn - Thank you for your insight! My thought was that it would be faster to write code that targets the actual underlying reference ID's - but that's probably already done by EF, or at least could be done by EF. I like the idea of implementation details being optionally scaffolded for observation - but I could probably think of 6,000 more important/useful features to build instead.
I have noticed that this EF model code templating system generates all related tables as shadow properties - is there a way to NOT do this, and actually include the SQL foreign keys in the model classes? My deepest apologies if this is already a feature, and I just haven't found it, or there is some kind of workaround. To be clear - I need to relate data based on an ID only - not by some EF tracked poco object. So, if I want "Course" "Mathematics" to be taught by "Teacher" "Bob", I can just add Bob's ID to the "Mathematics" "Course" "TeacherID" field in C#.