Sunday, July 27, 2014

When using an auto-incrementing integer with NHibernate as the unique id for both a C# object and a database table...

Prep the object just as you would an object that uses a Guid except:

  1. Use an integer.
  2. Do not specify the value when saving new objects.

 
 

When you fish objects back out of the database they will hold the appropriate id.

No comments:

Post a Comment