views:

37

answers:

1

The title basically says it all... I'm trying to specify an auto-incrementing (int) identity column using Fluent-NHibernate and MySQL. I've tried the following variations...

Id(x => x.ID).GeneratedBy.Native();
Id(x => x.ID).GeneratedBy.Identity();
Id(x => x.ID).GeneratedBy.Increment();

...and tried setting default values on each.

Note: I'm using an int data type and have received errors such as...

"Input string was not in a correct format."

or...

"Field 'ID' does not have a default value'

A: 

In MySQL you can create a column and mention its properties as AUTO_INCREMENT and DEFAULT VALUE 1 (or whatever you wish), why don't you use it?

--Cheers

Koteswara sarma
When Fluent-NHibernate generates the schema, it auto generates the column with a datatype of int(11) with auto-increment. There's no default value, but setting one didn't make a difference.
Adam
Argh... Web.config was using an old connection string where an older version of the database resided. After correcting that... "Id(x => x.ID).GeneratedBy.Identity();" worked with no problems.
Adam