开发者

Change column for joined class mapping in Fluent NHibernate Automapping

开发者 https://www.devze.com 2023-03-21 18:37 出处:网络
I have an inheritance public abstract class UserEntity : Entity { public virtual int Id { get; pr开发者_StackOverflowotected set; }

I have an inheritance

public abstract class UserEntity : Entity
{
    public virtual int Id { get; pr开发者_StackOverflowotected set; }
}

public class Employee : UserEntity
{
    public virtual string Email { get; set; }
}

Entity is a standard for NH class where overridden methods Equals, GetHashCode, etc. And I use AutMap rewriting .IncludeBase()

I got with 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>

I want to change name for key column in joined subclass from UserEntityId to EmployeeId

I try

public class UserEntityOverride : IAutoMappingOverride<UserEntity>
{
    public void Override(AutoMapping<UserEntity> mapping)
    {
        mapping.JoinedSubClass<Employee>("EmployeeId");
    }
}

but didn't have success.

I use the latest for this moment FNH from NuGet package: FluentNHibernate 1.2.0.712. Also I have much more configuration and conventions that can somehow affect on this configuration ignoring, but I have tried it on a clear solution with the same negative result.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号