Frank Krueger
Frank Krueger

Reputation: 71043

How do you make a column an auto incremented primary key in the various .NET ORMs?

How do you make a column (let's call it OrderID) an auto incremented primary key in the various .NET ORMs?

Linq To SQL

Entity Framework

NHibernate

I have started this question in order to have a one-stop answer to this question and to solicit more information from the .NET community. If you use an ORM not listed here, please edit this question and post the appropriate attributes.

Upvotes: 1

Views: 89

Answers (1)

GloryDev
GloryDev

Reputation: 680

In Habanero (http://www.habanerolabs.com/) you can either set it up via the ClassDef.Xml as follows:

property name="AutoIncrementingProp" type="Int32" autoIncrementing="true"

or you can set it up in Firestarter by ticking Autogenerate (This will generate the ClassDefs with autoIncrementing.

Or if you are using more fluent syntax i.e. you are not setting up you Business Objects via ClassDefs then you would do.

BOProp autoIncrementingProp = new BOProp(.......,true,.);

or autoIncrementingProp.AutoIncrementing = true;

Upvotes: 1

Related Questions