Fluent Nhibernate 正在添加两个 ID 列?

发布于 2024-11-27 12:51:48 字数 1283 浏览 1 评论 0原文

我有以下映射:

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 => 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");
    }

当 nhibernate 使用 SchemaExport 创建表时,我在 crm_people 表中得到两个 AccountId 列:

   AccountId
   Account_Id

任何人都可以阐明我做错了什么吗?

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 => 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉城凉梦凉人心 2024-12-04 12:51:48

菲尔在评论中所说的代码

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

what Phill in his comment said as code

public AccountMap()
{
    ...
    HasMany(x => x.People)
        .KeyColumn("AccountId")
        .Inverse();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文