Wrong type for SQL Server 2008 Identity column

Feb 11, 2009 at 8:36 PM
Edited Feb 11, 2009 at 8:39 PM
My Id column in my table keeps getting mapped to string instead of int when I use version 0.6

Connection string: Data Source=localhost;Initial Catalog=HelloFluentNHibernate;Integrated Security=SSPI;

For the following table in SQL Server 2008 Developer Edition:

/****** Object: Table [dbo].[Customers] Script Date: 02/11/2009 15:32:26 ******/

SET  ANSI_NULLS ON 
GO

 

SET

 

QUOTED_IDENTIFIER ON
GO

 

CREATE

 

TABLE [dbo].[Customers]
    
[Id] [int] IDENTITY(1,1) NOT NULL, 
    
[Firstname] [nvarchar](50) NOT NULL, 
    
[Lastname] [nvarchar](50) NOT NULL, 
    
[Email] [nvarchar](50) NULL, 
    
CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED ([Id] ASC )
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY] )
ON [PRIMARY] GO

 

I get the following C# class generated:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3082
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Sample.CustomerService.Domain {
    using System;
   
   
    public class Customers {
       
        private string email;
       
        private string firstname;
       
        private string id; // <- should be int
       
        private string lastname;
       
        public Customers() {
            System.Console.WriteLine("Inside Constructor ...");
        }
    }
}



And the following Customers.hbm.xml file generated:

<?

xml version="1.0" encoding="utf-8"?>

 

<

 

 

hibernate-mapping assembly="Sample.CustomerService.Domain" xmlns="urn:nhibernate-mapping-2.2">

 

<

 

 

class name="Sample.CustomerService.Domain.Customers, Sample.CustomerService.Domain" table="Customers" lazy="true" >

 

<

 

 

id name="id" type="String" column="Id" access="field">

 

<

 

 

generator class="identity" />

 

</

 

 

id>

 

<

 

 

property name="email" column="Email" access="field" />

 

<

 

 

property name="firstname" column="Firstname" access="field" />

 

<

 

 

property name="lastname" column="Lastname" access="field" />

 

</

 

 

class>

 

</

 

 

hibernate-mapping>

 

 

 


Coordinator
Mar 7, 2009 at 6:20 PM
Almost all the data type mismatch bugs are fixed now. Please use V0.7