无法编译映射文件 nhibernate
Could not compile the mapping document nhibernate
大家好,我是 nhibernate 的新手,您能帮我检查一下这里是否有问题吗?我正在使用 hbibernate + webapp mvc visual studio 2017:
private void BuildConfiguration()
{
//error here
Configuration.Configure(@"~\Models\hibernate.cfg.xml");
//already tried next command with same error
//Configuration.Configure(@"~\Models\hibernate.cfg.xml");
Configuration.AddAssembly(GetType().Assembly);
Configuration.AddFile(@"~\Mappings\Users.hbm.xml");
}
hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=(localdb)\SQLEXPRESS;database=dbtest;Integrated User ID=sa;Password=sa123;
</property>
<property name="dialect">
NHibernate.Dialect.MsSql2012Dialect
</property>
此问题与 asp .net core 2 httpcontext.current / nhibernate 兼容性问题有关
在
configuration.Configure();
configuration.AddFile();
我没有使用 httpcontex.current,我已经尝试过 Microsoft.AspNetCore.Session 和 IHttpContextAccessor 但当前仍然是 null
所以我决定转到 entity framework 那个项目。
大家好,我是 nhibernate 的新手,您能帮我检查一下这里是否有问题吗?我正在使用 hbibernate + webapp mvc visual studio 2017:
private void BuildConfiguration()
{
//error here
Configuration.Configure(@"~\Models\hibernate.cfg.xml");
//already tried next command with same error
//Configuration.Configure(@"~\Models\hibernate.cfg.xml");
Configuration.AddAssembly(GetType().Assembly);
Configuration.AddFile(@"~\Mappings\Users.hbm.xml");
}
hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=(localdb)\SQLEXPRESS;database=dbtest;Integrated User ID=sa;Password=sa123;
</property>
<property name="dialect">
NHibernate.Dialect.MsSql2012Dialect
</property>
此问题与 asp .net core 2 httpcontext.current / nhibernate 兼容性问题有关
在
configuration.Configure();
configuration.AddFile();
我没有使用 httpcontex.current,我已经尝试过 Microsoft.AspNetCore.Session 和 IHttpContextAccessor 但当前仍然是 null
所以我决定转到 entity framework 那个项目。