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 4623502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:59:47+00:00 2026-05-22T02:59:47+00:00

I have this override class: public class UserAutoMappingOverride : IAutoMappingOverride<User> { public void Override(AutoMapping<User>

  • 0

I have this override class:

public class UserAutoMappingOverride : IAutoMappingOverride<User>
{
    public void Override(AutoMapping<User> mapping)
    {
        mapping.ReadOnly();

        mapping.Cache.ReadOnly();

        mapping.Table("VIEW_ACTIVE_USERS");

        mapping.Id(x => x.Id, "ID")
            .GeneratedBy
            .Native("SEC_USERS_SEQ");

        mapping.NaturalId()
            .Property(x => x.Username, "ACTIVE_DIRECTORY_LOGIN")
            .ReadOnly();

        mapping.Map(x => x.EmailAddress, "EMAIL_ADDRESS");
        mapping.Map(x => x.FirstName, "FIRST_NAME");
        mapping.Map(x => x.LastName, "LAST_NAME");

        mapping.HasManyToMany<Role>(x => x.Roles)
            .ReadOnly()
            .Inverse()
            .Table("PFS_SEC_USERS_GROUPS_011")
            .ParentKeyColumn("SEC_USER_ID")
            .ChildKeyColumn("SEC_GROUP_ID")
            .Cascade.None()
            .AsSet();
    }
}

It results in this XML mapping being generated:

<class xmlns="urn:nhibernate-mapping-2.2" mutable="false" name="iPFSv2.Core.Security.User, iPFSv2.Core, Version=1.9.5.0, Culture=neutral, PublicKeyToken=null" table="VIEW_ACTIVE_USERS">
  <cache usage="read-only" />
  <id name="Id" type="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <column name="ID" />
    <generator class="native">
      <param name="sequence">SEC_USERS_SEQ</param>
    </generator>
  </id>
  <set cascade="none" inverse="true" name="Roles" table="PFS_SEC_USERS_GROUPS_011" mutable="false">
    <key>
      <column name="SEC_USER_ID" />
    </key>
    <many-to-many class="iPFSv2.Core.Security.Role, iPFSv2.Core, Version=1.9.5.0, Culture=neutral, PublicKeyToken=null">
      <column name="SEC_GROUP_ID" />
    </many-to-many>
  </set>
  <property name="EmailAddress" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <column name="EMAIL_ADDRESS" />
  </property>
  <property name="FirstName" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <column name="FIRST_NAME" />
  </property>
  <property name="LastName" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <column name="LAST_NAME" />
  </property>
  <property name="Username" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <column name="Username" />
  </property>
</class>

As you can see, some of the overrides are working, but the natural ID override is not. Am I doing something wrong or is this a bug? Looking at the properties for my DLL it looks like I am using assembly version 1.2.0.694.

  • 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-22T02:59:48+00:00Added an answer on May 22, 2026 at 2:59 am

    I’ve confirmed that this is a bug. I downloaded the latest master branch from github and added the following test to the AutoPersistenceModelTests.Overrides.cs file:

        [Test]
        public void NaturalIdOverrideShouldOverrideExistingProperty()
        {
            var autoMapper = AutoMap.AssemblyOf<ExampleClass>()
                .Where(t => t.Namespace == "FluentNHibernate.Automapping.TestFixtures")
                .Override<ExampleClass>(c => c.NaturalId().Property(x => x.LineOne, "test"));
    
            var a = new AutoMappingTester<ExampleClass>(autoMapper);
    
            new AutoMappingTester<ExampleClass>(autoMapper)
                .Element("//natural-id/property[@name='LineOne']")
                .Exists()
                .HasThisManyChildNodes(1)
                .Element("//natural-id/property[@name='LineOne']/column").HasAttribute("name", "test");
        }
    

    The test fails. Natural ID override is not working.

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

Sidebar

Related Questions

I have this ActionFilter public class AppOfflineFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext
I have this code: public class Home extends Activity{ @Override public void onCreate(Bundle savedInstanceState)
I have this code: @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glClearColor(0, 0,
I have this structure: 1) main activity: public class mainActivity extends Activity { @Override
I have this as my DefaultControllerFactory override: public class StructureMapControllerFactory : DefaultControllerFactory { protected
i have this example: class One { public void testOne(){System.out.println(One!!!);} public void testTwo(){System.out.println(One!!!);} }
i have this Dependency resolver public class NinjectDependencyResolvercs : IDependencyResolver { private readonly IResolutionRoot
I have this code: @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws
i have this class: public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { ImageFromWeb ifw;
I have this piece of code: public class Authenticate : ActionFilterAttribute { public override

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.