的app.configNHibernate的MappingException,沒有留存爲:NHiberDeneme.Sinifi
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=localhost;Initial Catalog=hiberdb;Integrated Security=True;</property>
<property name="default_schema">hiberdb.dbo</property>
<mapping assembly="NHiberDeneme"/>
</session-factory>
</hibernate-configuration>
</configuration>
的Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Cfg;
using NHibernate;
namespace NHiberDeneme
{
class Program
{
static void Main(string[] args)
{
Configuration cfg = new Configuration();
cfg.AddAssembly("NHibernate"); // projenin assembly Adi
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
Sinifi sinif = new Sinifi();
sinif.Id = 1;
sinif.SinifAdi = "sinif adi";
session.Save(sinif);
session.Flush();
session.Clear();
transaction.Commit();
session.Close();
}
}
}
Sinifi.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Mapping;
namespace NHiberDeneme
{
class Sinifi
{
private int _id;
private string _sinifadi;
public int Id
{
get { return _id; }
set { _id = value; }
}
public string SinifAdi
{
get { return _sinifadi; }
set { _sinifadi = value; }
}
}
}
Sinifi.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHiberDeneme.Sinifi, NHiberDeneme.Program, NHiberDeneme" table="Sinifi" lazy="false">
<id name="Id" column="Id" type="int">
<generator class="assigned" />
</id>
<property name="SinifAdi" column="SinifAdi" type="String" length="10"/>
<bag name="SinifiId" table="SinifiId" inverse="true">
<key column="Id" />
<one-to-one class="NHiberDeneme.Sinifi, NHiberDeneme.Program, NHiberDeneme" />
</bag>
</class>
</hibernate-mapping>
我的SQL關係在這裏http://i.stack.imgur.com/jOT5M.jpg
給我 「MappingException,沒有留存爲:NHiberDeneme.Sinifi」 的錯誤。我嘗試了很多方法,我也嵌入了資源。