【发布时间】:2014-12-07 23:31:21
【问题描述】:
在 NHibernate 中使用按代码映射/符合标准的方法时,如何创建类映射以便将 Person.CountryId 创建为我的 Country 实体的外键?
在加载 Person 实体时,我确实不想直接在 person 实体中使用 Country 实体(因为它们是不同的聚合根)但仅通过 ID 引用它并且仍然具有 FK 关系在数据库中定义。
public class Person : Entity, IEntity
{
public Guid CountryId { get; protected set; }
}
public class Country : Entity, IEntity
{
public string Name { get; protected set; }
}
【问题讨论】:
标签: c# nhibernate orm nhibernate-mapping