I am working very first time with FluentNHibernate, attempting to map classes to SQL Express database. Generally it really works, but I am not able to map Double or Decimal property types to a particular scale/precision. Below shows result for any single property which i examined again and again with SchemaUpdate.Execute. In no situation was I capable of getting results.

Could be really useful to listen to some explanation towards the mappings that doesn't act 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,) - Why precision may be the default mapping here?

3) Double: Map(Function(x) x.Balance) >> Float , However when running SchemaValidator after: HibernateException: Wrong column key in FnhDb.dbo.Take into account column Balance. Found: float, Expected DOUBLE PRECISION

4) Decimal: Map(Function(x) x.Balance).Scale(9).Precision(2) >> SqlException: The size (9) for column 'Balance' should be inside the range to two.

5,6) Decimal or Double: Map(Function(x) x.Balance).Scale(9).Precision(2).CustomSqlType("number") >> number(18,)

7,8) Decimal or Double: Map(Function(x) x.Balance).Scale(9).Precision(2).CustomSqlType("decimal") >> Decimal(18,)


EDIT: I include code and hbm.xml (export) for situation (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 isn't a VB problem. I've the identical condition in a C# project. Will it function as the MsSql2008 configuration that's not suitable for 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