this is ASP.NET MVC 5 Sample App. trying to learn MVC's module NHibernate.
if I understand right. hibernate.cfg.xml file is not neccessary if settings coded in web.config as a configsection.
is xmlns version is wrong ? or do you see something misspelled ? so why NHibernate asks hibernate.cfg.xml even if web.config configured? (thanks)
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate" />
...
<hibernate-configuration xmlns="urn:nhibernate-configuration-version-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string_name">LocalMySqlServer</property>
</session-factory>
</hibernate-configuration>
getting this error:
Could not find file '...\Visual Studio 2013\Projects\bin\Debug\hibernate.cfg.xml'.
and DB Class static member (which used once in global.asax.cs Application_Start method) is:
public static void Configure()
{
var config = new Configuration();
config.Configure();
var mapper1 = new ModelMapper();
mapper.AddMapping<UserMap>();
config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
_sessionFactory = config.BuildSessionFactory();
// _session factory is a class member defined as
// private static ISessionFactory _sessionFactory;
}
NHibernate 4.0.3.4000 installed [using nuget]
found the answer. it seems scheme key is changed in new nhibernate version
changed
<hibernate-configuration xmlns="urn:nhibernate-configuration-version-2.2">
to
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
fixes the problem. Im sure because I retested back the first scheme. and boM! same error throw. so xmlns string is updated.
how I found it. opened web.config>xml in menu>Schemes [added nhibernate xsd files which you can find in your project\packages] than autocompletion did worked in web.config and shown to me the correct schema string.