The key point is that the KeyColumn is at the BASE table. You can see that there is a one-to-many relationship between User and Follow from the following code.
public class Activity
{
public virtual User Executor { get; set; }
//probably I should set some kind of Polymorphism here?
}
public class Follow : Activity
{
public virtual User Followee { get; set; }
}
public class User
{
public virtual IList<Follow> Follows { get; set; }
}
so I mapped them as the following:
public class ActivityMap : EntityMap<Activity>
{
public ActivityMap()
{
References<User>(m => m.Executor);
}
}
public class FollowMap : SubclassMap<Follow>
{
public FollowMap()
{
References(m => m.Followee);
}
}
public class UserMap : EntityMap<User>
{
public UserMap()
{
HasMany(m => m.Follows)
.Inverse();
//.KeyColumn("Executor_id");
}
}
Please notice the KeyColumn() map. "Executor_id" is not in table tb_Follow but in table tb_Activity(for subclass strategy). If code like the above, a new column "Executor_id" will be generated in tb_Follow, which I think duplicated.
Now how can I refer to the "Executor_id" column in tb_Activity?
PS: the table structure.
tb_Follow
+-------------+-------------+---------+
+ Activity_id + Followee_id + User_id +
+-------------+-------------+---------+
+ 1 + 7 + NULL +
+-------------+-------------+---------+
tb_Activity
+-------------+-------------+---------+
+ id + Executor_id + Type +
+-------------+-------------+---------+
+ 1 + 6 + Follow +
+-------------+-------------+---------+
so it's User(6) -- follow --> User(7)
the User_id should be 6 in my resolution, the same(and I think duplicated) with Executor_id