Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6223733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:32:27+00:00 2026-05-24T08:32:27+00:00

Domain: public class Account { public virtual int AccountId { get; set; } public

  • 0

Domain:

 public class Account
{

    public virtual int AccountId { get; set; }
    public virtual int UserId { get; set; }
    public virtual string HostName { get; set; }
    public virtual DateTime CreatedOn { get; set; }
    public virtual bool Deleted { get; set; }
}

public class Person
{
    public Person()
    {
        PersonRoles = new List<PersonRole>();
    }
    public virtual int PersonId { get; set; }
    public virtual Guid PersonGuid { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string Surname { get; set; }
    public virtual string Email { get; set; }
    public virtual string Password { get; set; }
    public virtual string SaltKey { get; set; }
    public virtual int PersonType { get; set; }
    public virtual DateTime CreatedOn { get; set; }
    public virtual bool Deleted { get; set; }
    public virtual bool Active { get; set; }
    public virtual int? AccountId { get; set; }

    public virtual ICollection<PersonRole> PersonRoles { get; private set; }
    public virtual Account Account { get; set; }
}

Mapping:

 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);
        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);

        HasManyToMany<PersonRole>(x => x.PersonRoles)
            .ParentKeyColumn("RoleId")
            .ChildKeyColumn("PersonId")
            .Cascade.All()
            .Table("crm_people_roles_mapping");

        //Map(x => x.AccountId);
        References(x => x.Account, "AccountId").Column("AccountId");
        Table("crm_people");
    }

Issue:

When saving a new person with an account id everything saves OK except for the acccount id field.

A person doesn’t need to have an account to exist.

What am I doing wrong?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:32:28+00:00Added an answer on May 24, 2026 at 8:32 am

    HNibernate doesn’t know what to do with your AccountId. On your person object, you’ve got an Account and an AccountId property. I’ll bet if you assigned the Account to the person before you save it, it’d all start working.

    Get rid of that AccountId property. You don’t need it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a domain object: class BirthdayDomain { public DateTime Birthday { get; set; }
I've got two theoretical domain objects: public class Person { public virtual int Id
Assume I have this domain object... public class SpansMultipleTables { public int CommonID {get;
I have a domain class like this: public class DomainClass { public virtual string
I have this: namespace Demo.Framework.Domain { public class UserEntity { public virtual Guid UserId
I have the following domain: public class FileInformation { public String FileName; public String
If I have the following domain object: public class Customer { public virtual Guid
I have the following domain class: public class Product { public virtual Guid Id
I have the following Domain Object: public class DomainClass { public int Id {
I have the following domain model: public class Name { private readonly string fullName;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.