Hello, i'm trying to develop a simple NHibernate Console application, but i'm getting an exception as follow:
"Could not compile the mapping document: <directory>\Carro.hbm.xml"
Carro.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Entidades">
<class name="Carro" table="carro">
<id name="Id">
<column name="id" sql-type="Int32" not-null="true"/>
<generator class="hilo" />
</id>
<property name="Descricao">
<column name="descricao" not-null="true" />
</property>
<property name="Fabricante">
<column name="fabricante" sql-type="Int32" not-null="true" />
</property>
</class>
</hibernate-mapping>
Carro.cs
Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace Entidades
{
class Carro
{
private Int32 id;
private string descricao;
private Int32 fabricante;
public virtual Int32 Id
{
get { return id; }
set { id = value; }
}
public virtual string Descricao
{
get { return descricao; }
set { descricao = value; }
}
public virtual Int32 Fabricante
{
get { return fabricante; }
set { fabricante = value; }
}
}
}
App.config
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- Add this element -->
<configSections>
<section
name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"
/>
</configSections>
<!-- Add this element -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Server=localhost;Database=hibexamples;User ID=root;Password=123456</property>
</session-factory>
</hibernate-configuration>
</configuration>