How do you make a column (let's call it OrderID
) an auto incremented primary key in the various .NET ORMs?
Linq To SQL
[Column(Name="OrderID", IsPrimaryKey=true, IsDbGenerated=true)]
Entity Framework
[EdmScalarProperty(EntityKeyProperty=true, IsNullable=false)]
(Not possible to specify autoinc?)
NHibernate
[Id(Name = "OrderId"), Generator(1, Class ="Identity")]
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.