I'm learning NHibernate to learn a more robust ORM than linq to sql, but i'm struggling with some simple things.
My first challenge is mapping this ID column using hbm.xml.
CREATE TABLE [dbo].[Party](
[Id] [int] IDENTITY(1,1) NOT NULL
CONSTRAINT [PK_Party] PRIMARY KEY CLUSTERED
(
[Id] ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
When I use the following mapping, i get a weird exported schema DDL
<class name="Party" table="Party">
<id name="Id">
<column name="Id" />
<generator class="native" ></generator>
</id>
</class>
which generates the following using the export tool
create table Party (
Id INT IDENTITY NOT NULL,
primary key (Id)
)
using Nhibernate, how can I add the clustered primary key and auto-incrementing Id?
Or, is the way of the world in NHibernate to keep your db schema separate from the mapping and use generator=native?
I'm starting to think NHibernate shouldn't be used for schema generation if you've already got a db schema that's fine tuned to a particular server.
Any help is greatly appreciated.