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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:56:46+00:00 2026-06-18T15:56:46+00:00

Before posting this question, I’ve seen a lot of examples on NH Versioning and

  • 0

Before posting this question, I’ve seen a lot of examples on NH Versioning and all of those tells me using below code; I can have a versioned-entity using MappingByCode:

Version(e => e.MyVersion, vm => {
     vm.Generated(VersionGeneration.Always);
     vm.UnsavedValue(0);
});

I expected that assigning MyVersion should be done by SQL Server. So when I call ISession.Save or ISession.SaveOrUpdate; NHProf shows generated sql contains no MyVersion parameter passed to Insert statement (as expected) but query execution goes to be failed because SQL Server doesn’t generate it; and result is cannot insert null value into MyVersion column... error.

My expectation about VersionGeneration.Always is correct? so what’s wrong?

I’m using NHibernate 3.3 / SQL Server 2012

  • 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-18T15:56:47+00:00Added an answer on June 18, 2026 at 3:56 pm

    VersionGeneration.Always means that NHibernate should expect the database system to generate the version number both on INSERT and on UPDATE.

    But you also need to tell SQL Server that it’s supposed to generate the number…
    See for instance http://msdn.microsoft.com/en-us/library/ms182776.aspx.

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

Sidebar

Related Questions

Before you all get pissy about me posting this question again, let me explain
I have seen the following links before posting this question http://www.devx.com/wireless/Article/40792/1954 Saving Android Activity
I did check those posts about Infinite gallery before posting this question but it
Actually found a lot of question like this before posting but doesn't find one
NOTE : Right before posting this question it occurred to me there's a better
I searched StackOverflow before posting this question but I wasn't able to find the
I have done my research before posting this question and I can not find
Ok, I hope I've got everything listed up nicely before posting this question because
I did scour the net and stackoverflow before posting this question, so forgive me
I just go through Google search before posting this question here but I am

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.