I'm working first time with FluentNHibernate, trying to map classes to SQL Express database. In general it works, but I'm unable to map Double or Decimal property types to specific scale/precision. Below shows result for a single property that I tested over and over with SchemaUpdate.Execute. In no case was I able to get it to work.
Would be really helpful to hear some explanation to the mappings that does not work as I expect (2-8)?
// Ok mappings:
1) Decimal: Map(Function(x) x.Balance) >> Decimal(19, 5)
// Mappings "errors":
2) Double: Map(Function(x) x.Balance).CustomSqlType("decimal") >> Decimal(18,0) - Why 0 precision is the default mapping here?
3) Double: Map(Function(x) x.Balance) >> Float , But; when running SchemaValidator after: HibernateException: Wrong column type in FnhDb.dbo.Account for column Balance. Found: float, Expected DOUBLE PRECISION
4) Decimal: Map(Function(x) x.Balance).Scale(9).Precision(2) >> SqlException: The scale (9) for column 'Balance' must be within the range 0 to 2.
5,6) Decimal or Double: Map(Function(x) x.Balance).Scale(9).Precision(2).CustomSqlType("numeric") >> numeric(18,0)
7,8) Decimal or Double: Map(Function(x) x.Balance).Scale(9).Precision(2).CustomSqlType("decimal") >> Decimal(18,0)
EDIT: I include code and hbm.xml (export) for case (4) here:
Public Class AccountMap
    Inherits ClassMap(Of Account)
    Public Sub New()
        MyBase.New()
        Id(Function(x) x.Id).GeneratedBy.Identity()
        Map(Function(x) x.Balance).Scale(9).Precision(2)   
        Map(Function(x) x.Deposits)
        Map(Function(x) x.WithDrawals)
    End Sub
End Class
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="none" default-lazy="false">
  <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="RoboTrader.Account, RoboTrader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="`Account`">
    <id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Id" />
      <generator class="identity" />
    </id>
    <property name="Balance" type="System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Balance" precision="2" scale="9" />
    </property>
    <property name="Deposits" type="System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Deposits" />
    </property>
    <property name="WithDrawals" type="System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="WithDrawals" />
    </property>
  </class>
</hibernate-mapping>
EDIT2:
Btw, this is not a VB issue. I have the exact same problem in a C# project. Can it be the MsSql2008 configuration that is not compatible with Sql Express 2008 R2?
EDIT3:
Option Strict On
Imports System.Collections.Generic Imports System.Text Imports System
Public Class Account
    Public Sub New()
        MyBase.New()
End Sub
Private _Id As Integer
Private _Balance As Double
Private _Deposits As Integer
Private _WithDrawals As Integer
Public Overridable Property Id() As Integer
    Get
        Return _Id
    End Get
    Set(ByVal value As Integer)
        _Id = value
    End Set
End Property
Public Overridable Property Balance() As Double
    Get
        Return _Balance
    End Get
    Set(ByVal value As Double)
        _Balance = value
    End Set
End Property
Public Overridable Property Deposits() As Integer
    Get
        Return _Deposits
    End Get
    Set(ByVal value As Integer)
        _Deposits = value
    End Set
End Property
Public Overridable Property WithDrawals() As Integer
    Get
        Return _WithDrawals
    End Get
    Set(ByVal value As Integer)
        _WithDrawals = value
    End Set
End Property
End Class
 
     
    