我有以下表格:Users
,RemindersFor
,Reminders
。 RemindersFor包含UserID
和ReminderID
,用户有Id
,提醒有Id
。
在用户地图文件中(使用Fluent NHibernate)我把:
HasManyToMany<Reminder>(f => f.Reminders).AsBag()
.Table("RemindersFor").ParentKeyColumn("UserID").ChildKeyColumn("ReminderID");
然而,我得到例外:Invalid column name 'Id'.
NHibernate生成的SQL是:
{“无法初始化集合:[提醒#2] [SQL:SELECT reminders0_.UserID as UserID1_,reminders0_.ReminderID as ReminderID1_,reminder1_.Id as Id6_0_,reminder1_.Created as Created6_0_,reminder1_.CreatedBy as CreatedBy6_0_, reminder1_.ReminderDate为Reminder4_6_0_,reminder1_.HeaderText为HeaderText6_0_,reminder1_.ReminderText为Reminder6_6_0_,reminder1_.LinkDS为LinkDS6_0_,reminder1_.LinkRecID为LinkRecID6_0_,reminder1_ .Action为Action6_0_,reminder1_.ActionNotes为ActionN10_6_0_ FROM RemindersFor reminders0_ left outer join提醒提醒1_开reminders0_.ReminderID = reminder1_.Id WHERE reminders0_.UserID =?]“}
我觉得很奇怪,当我运行它时,sql管理工作室可以正常工作(除了我必须将UserID=?
更改为UserID=1
等...
我是否以某种方式定义了多对多的错误?