【发布时间】:2011-10-04 15:25:48
【问题描述】:
外键的映射使用了错误的名称。为什么?
这是我的课程:
属性的顺序似乎很重要:
public class Person
{
public virtual Person Mother { get; set; }
public virtual IList<Item> Items { get; set; }
public virtual Person Father { get; set; }
}
public class Item
{
public virtual string Name { get; set; }
}
这是 Fluent Nhibernate 的映射
AutoMap.AssemblyOf<Person>(new CustomAutomappingConfiguration())
当我查看数据库时,表中的外键似乎是属性 Items 之后类型为 Person 的第一个属性的名称。这是为创建表而生成的 SQL:
CREATE TABLE "Item" (Id integer primary key autoincrement
, Name TEXT
, Father_id BIGINT
, constraint FKC57C4A2B4586680 foreign key (Father_id) references Patient)
提前感谢您的帮助;)
【问题讨论】: