Jonas Cannehag
Jonas Cannehag

Reputation: 391

Subsonic ActiveRecord and foreign key property names

my first question here on Stackoverflow (wish me luck :))

So, I have a new site on my mind that I would like to create using as much "generation"-friendly stuff as possible due to the fact that I'm getting tired of coding the same stuff all over again.

This has made me take a peek at the SubSonic project (have been looking at the other stuff created by Rob as well) and I really like the concept. The only thing on my mind is the scenario where I have created my database-model using the ASP.NET "build-in" Membership provider.

The stuff I am currently facing is the fact that if I have, for example, a News table with an EditorID and a CreatorID column which are both a foreign key to the aspnet_Users table, this gets me in to kind of a trouble. The properties generated on my News class will be named aspnet_Users and aspnet_Users1

Is there some way of hijacking this process and having it make use of the foreign key name or something? I would like to have these properties called Editor and Creator of course.

Is this possible?

Upvotes: 3

Views: 408

Answers (1)

user1151
user1151

Reputation:

My first thought is you don't want to do this (the FK to the membership table). While convenient - you're tying your design to another system which can be an issue.

What I might suggest is having an intermediary table - Users if you will - and leave the FK relationship off.

That said - yes you should be able to tweak the templates (assuming you're using 3.0) to accomodate your needs.

Upvotes: 1

Related Questions