开发者

Fluent Nhibernate is adding two ID columns?

I have the following mappings:

public AccountMap()
    {
        Id(x => x.AccountId, "AccountId").Column("AccountId");
        Map(x => x.UserId);
        Map(x => x.HostName);
        Map(x => x.CreatedOn);
        Map(x => x.Deleted);
        HasMany(x => x.People);
        Table("crm_accounts");
    }

  public PersonMap()
    {
        Id(x => x.PersonId).Column("PersonId");
        Map(x => x.PersonGuid);
        Map(x => x.FirstName);
        Map(x => x.Surname);
        Map(x => x.Email);
        Map(x => x.Password);
        Map(x => x.SaltKey);
        Map(x => x.PersonType);
        Map(x => x.CreatedOn);
        Map(x =&g开发者_StackOverflowt; x.Deleted);
        Map(x => x.Active);
        //Map(x => x.AccountId, "AccountId");

        HasManyToMany<PersonRole>(x => x.PersonRoles)
            .ParentKeyColumn("RoleId")
            .ChildKeyColumn("PersonId")
            .Cascade.All()
            .Table("crm_people_roles_mapping");
        References(x => x.Account, "AccountId").Column("AccountId").Cascade.All();
        Table("crm_people");
    }

When nhibernate creates the tables using SchemaExport I am getting two AccountId columns in my crm_people table as so:

   AccountId
   Account_Id

Can anyone shed light on what I am doing wrong?


what Phill in his comment said as code

public AccountMap()
{
    ...
    HasMany(x => x.People)
        .KeyColumn("AccountId")
        .Inverse();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜