Я использую Visual Studio 2010 с NHibernate 3.2.0.GA, у меня есть веб-приложение со следующим файлом Web.Config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name ="Nhibernate.Test">
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">
Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Mahshid\Desktop\BugTracker\BugTracker\App_Data\BugTrackerDB.mdf;
Integrated Security=True;User Instance=True
</property>
<property name ="adonet.batch_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">Nhibernate.Dialect.MsSql2008Dialect</property>
<property name="command_timeout">60</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
NHiberante.ByteCode.LinFu</property>
</session-factory>
</hibernate-configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
Я добавил свою базу данных sql как локальную внутриvs2010, у меня также есть два файла nhibernate hbm.xml со следующими параметрами:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="BugTracker.Model"
assembly ="BugTracker">
<class name="Bug" table ="Bugs" lazy="false">
<id name ="BugId" column ="BugId" type="int"
unsaved-value="0">
<generator class="native"/>
</id>
<property name="Desc" column="Description"/>
<property name="Fixed" column ="Fixed"/>
<many-to-one name="Application"
class="Application"
column="ApplicationId"
cascade="all"
not-null="true"/>
</class>
</hibernate-mapping>
И:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="BugTracker.Model"
assembly="BugTracker">
<class name="Application" table="Applications" lazy="false">
<id name="ApplicationId" column ="ApplicationId" type="int" unsaved-value ="0">
<generator class ="native"></generator>
</id>
<property name ="Name" column="Name"/>
<component access ="field.camelcase-underscore" name ="Developer"
class="Developer">
<property access ="field.camelcase-underscore"
column ="DeveloperFirstName" name="FirstName"/>
<property access ="field.camelcase-underscore"
column="DeveloperLastName" name="LastName"/>
</component>
<bag cascade="all-delete-orphan"
inverse ="true"
name ="Bugs"
lazy="false"
access ="field.camelcase-underscore">
<key column ="ApplicationId"/>
<one-to-many class ="Bug"/>
</bag>
</class>
</hibernate-mapping>
Я установил их как встроенный ресурс, поверьте мне, но я получаю исключениев следующей части кода:
private static void Init()
{
NHibernate.Cfg.Configuration config;
config = new NHibernate.Cfg.Configuration();
config.AddAssembly("BugTracker");
config.Configure();
_SessionFactory = config.BuildSessionFactory();
}
С этим сообщением:
Could not compile the mapping document: BugTracker.Model.Bug.hbm.xml
Внутреннее сообщение об исключении:
Could not instantiate dialect class Nhibernate.Dialect.MsSql2008Dialect
Я знаю, что это проблема новичка, но яЯ просто новичок!но я ценю ваши идеи ...