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

  • Home
  • SEARCH
  • 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 9168121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:33:24+00:00 2026-06-17T15:33:24+00:00

if i have a convention for mapping ids that is how i generally map

  • 0

if i have a convention for mapping ids that is how i generally map that uses the hilo generatior on an int Id property with an int Id column:

public class IdConvention : IIdConvention
{
    private const int HiLoRange = short.MaxValue;

    public void Apply(IIdentityInstance instance)
    {
        instance.Column(instance.EntityType.Name + "Id");
        instance.GeneratedBy.HiLo(HiLoRange.ToString());
    }
}

but i have a class i want to map differently, with an assigned string as the Id instead, i use an override:

public class SomeClassMapping : IAutoMappingOverride<SomeClass>
{
    public void Override(AutoMapping<SomeClass> mapping)
    {
        mapping.Id(instance => instance.StringProperty).GeneratedBy.Assigned().Column("StringProperty");
    }
}

this worked in older versions of FluentNHibernate/NHibernate, but when i update to 1.3.0.733/3.3.2.4000, i now fall victim to an unhandled exception:

System.InvalidOperationException: Identity type must be integral (int, long, uint, ulong)

this only happens if i’m trying to use a string (or some other non-integral property as the Id) should i expect that i’m no longer able to override a mapping and give a different generator and type, or is there something i can do differently to make the override hide that i want to do hilo in the general case?

  • 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-06-17T15:33:26+00:00Added an answer on June 17, 2026 at 3:33 pm

    looks like the order of execution changed. an easy fix would be to

    public void Apply(IIdentityInstance instance)
    {
        if (instance.Type == typeof(int))
        {
            instance.Column(instance.EntityType.Name + "Id");
            instance.GeneratedBy.HiLo(HiLoRange.ToString());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of POCO objects that look like this: public abstract class
I have the following HasMany convention: instance.Key.Column( instance.EntityType.Name + Fk ); instance.Inverse(); instance.Cascade.All(); That
I have an existing NHibernate 2.1.2.4000 mapping that uses the mapping syntax: <database-object> <create>
I have a base class called Entity: public class Entity { public int Id
I have a fluent mapping of a domain class that defines the names for
We are using Fluent NH with convention based mapping. I have the following: public
Here I have the mapping for the parent and child-class: public class Parent {
We have a convention to validate all parameters of constructors and public functions/methods. For
I have many js files, with some naming convention. If there any tool that
I have an abstract entity base class defined like this: public abstract class SessionItem

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.