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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:17:13+00:00 2026-05-21T02:17:13+00:00

I`m a newbie in Fluent Nhibernate. I have a PostgreSQL database and what I

  • 0

I`m a newbie in Fluent Nhibernate.

I have a PostgreSQL database and what I want is a generated id with auto increment.
I have not seen feature auto increment in PostgreSQL and I understand that to use auto increment in PostgreSQL I have to create a sequence.

Is there another way besides sequences?

If create sequence is the only way, can you tell me how I should mapping it?
I tried to use this and had no success:

mapping.Id(x => x.Id, "id").GeneratedBy.Sequence("hibernate-sequence");

I have created hibernate-sequence before using it.

Regards

  • 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-21T02:17:14+00:00Added an answer on May 21, 2026 at 2:17 am

    Strange, but with your code an insertion works fine, if you call Save(Object) instead of SaveOrUpdate(Object)

    Edit #1

    That’s what worked for me.

    Entity:

    public class Human
    {
        public virtual int ID { get; set; }
        public virtual string Name { get; set; }
    }
    
    public class HumanMap : ClassMap<Human>
    {
        public HumanMap()
        {
            this.Id(x => x.ID).CustomSqlType("Serial").GeneratedBy.Native();
            this.Map(x => x.Name);
        }
    }
    

    And configuration with schema export:

    static ISessionFactory CreateSF()
    {
        return Fluently
        .Configure()
        .Database(PostgreSQLConfiguration.Standard.ConnectionString("Server=127.0.0.1;Port=5432;Database=fnhtest;User=postgres;Password=password"))
        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Program>())
        .ExposeConfiguration(cfg => { new SchemaExport(cfg).Create(false, true); })
        .BuildSessionFactory(); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newbie with Fluent NHibernate and have got a question that may
This is a Fluent NHibernate newbie question, so bear with me. I have a
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Imagine the following (simplified) database layout: We have many holiday records that relate to
I'm a bit of a Fluent nHibernate newbie, so forgive me is this is
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
I am newbie to NHibernate and trying to use Fluent for mapping. My entity
Newbie IIS question: I want to setup HTTPS access for my XHTML page (not
Extreme newbie question. I have my database (SQL Server) set up to cascade deletes
newbie question I have a multiselect box that i populate with some ajax and

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.