我有遗产
public abstract class UserEntity : Entity
{
public virtual int Id { get; protected set; }
}
public class Employee : UserEntity
{
public virtual string Email { get; set; }
}
实体是 NH 类的标准,其中覆盖了 Equals、GetHashCode 等方法。我使用 AutMap 重写 .IncludeBase()
我得到了 Fluent NHibernate Automapping
<class xmlns="urn:nhibernate-mapping-2.2" name="Dto.Entities.UserEntity" table="UserEntities">
<id name="Id" type="System.Int32">
<column name="Id" />
<generator class="identity" />
</id>
<joined-subclass name="Dto.Entities.Employee" table="Employees">
<key foreign-key="FK_Employee_UserEntity">
<column name="UserEntityId" />
</key>
<property name="Email" type="System.String">
<column name="Email" />
</property>
</joined-subclass>
</class>
我想将连接子类中键列的名称从 UserEntityId 更改为 EmployeeId
我试试
public class UserEntityOverride : IAutoMappingOverride<UserEntity>
{
public void Override(AutoMapping<UserEntity> mapping)
{
mapping.JoinedSubClass<Employee>("EmployeeId");
}
}
但没有成功。
我现在使用来自 NuGet 包的最新 FNH:FluentNHibernate 1.2.0.712。此外,我还有更多的配置和约定可能会以某种方式影响忽略此配置,但我已经尝试了一个明确的解决方案,但结果相同。