That’s not entirely accurate. I have a user table and some/most Users are Trainers. There is a UserRole that specifies if a User is a Trainer or an Admin, and that’s the only difference. Perhaps not the cleanest structure, but often Admins are Trainers too and it works fine.
So I’ll have a table like TrainerPayment. It has a some payment information and a Trainer associated with it which of course is a User. so
public int User Trainer {get;set;}
so when I use NH to create the schema I get
PaymentName varchar(250)
PaymentAmount double
TrainerId int FK
UserId int FK
and then NH uses both of those FK’s for different queries. So for instance, If I do a load(trainerId) it generates sql that looks for userid=2. And somewhere else it does a query and uses trainerId. Sorry I forgot where that happened, but I tried to remove the TrainerId and I got an error. I can look it up if you think it would help.
If it’s not clear my question is why do I need both of those FKs ? It really seems like I should only need one.
Thanks,
Raif
I’d guess you have one-to-many on the User that maps to the TrainerPayment? You need to tell that one-to-many that the FK on the TrainerPayment table is called TrainerId, not UserId like the one-to-many will default too.