FluentNHibernate映射smalldatetime SQL数据类型

时间:2013-10-03 22:09:25

标签: sql nhibernate fluent-nhibernate fluent-nhibernate-mapping smalldatetime

我有一个使用smalldatetime SQL数据类型的旧数据库。这可以很好地映射到标准DateTime。但是,当我使用SchemaExport时,可以理解地生成datetime格式的列。我应该在映射中使用哪种自定义类型,以便生成的列为smalldatetime

   // Does not work as custom type not known       
   Map(x => x.BirthDate).Column("dtBirthDate").Not.Nullable().CustomType("smalldatetime");

1 个答案:

答案 0 :(得分:1)

你几乎拥有它,而不是.CustomType你必须定义.CustomSqlType

Map(x => x.BirthDate)
    .Column("dtBirthDate")
    .Not.Nullable()
    .CustomSqlType("smalldatetime")
    .CustomType("datetime")

刚测试它,它将创建一个带有smalldatetime的数据库列。

相关问题