简体   繁体   English

无法编译映射文件Nhibernate

[英]Could not compile the mapping document nhibernate

Hi all Im kind of new in nhibernate, can you please help me to check if there is something wrong here? 大家好,我是nhibernate的新用户,您能帮我检查一下这里是否有问题吗? im using hbibernate + webapp mvc visual studio 2017: 我正在使用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 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>

this issue was related to the asp .net core 2 httpcontext.current / nhibernate compatibility problem 此问题与ASP .NET Core 2 httpcontext.current / nhibernate兼容性问题有关

in the 在里面

configuration.Configure();
configuration.AddFile();

i wasnt using httpcontex.current, i already tried Microsoft.AspNetCore.Session and IHttpContextAccessor but the current is still null 我没有使用httpcontex.current,我已经尝试过Microsoft.AspNetCore.Session和IHttpContextAccessor,但是当前仍然为null

so i decided to move to entity framework in that project. 所以我决定在该项目中转向实体框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM