如何使用Fluent-NHibernate和MySQL指定自动递增(int)标识列 [英] How to specify an auto-incrementing (int) identity column using Fluent-NHibernate and MySQL
问题描述
lockquote
Id(x => x.ID).GeneratedBy.Native(); >
Id(x => x.ID).GeneratedBy.Identity();
Id(x => x.ID).GeneratedBy.Increment();
...并尝试设置每个默认值。
注意:我正在使用int数据类型,并收到错误,如...
输入字符串格式不正确。
或...
字段'ID'没有默认值'
在MySQL中,您可以创建一个列,并提及其属性为AUTO_INCREMENT和DEFAULT VALUE 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'
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
这篇关于如何使用Fluent-NHibernate和MySQL指定自动递增(int)标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!