NHibernate異常之:Unknown entity class: EDP.Provider.User

來源:互聯網
上載者:User

調試是出現這個錯誤:

MappingException: Unknown entity class: EDP.Provider.User

映射錯誤,未知的實體類User。

本以為是User的對應檔配置錯誤,但是確認User的對應檔User.hbm.xml沒有錯誤且已經將其嵌入工程,不是這兒的問題,那麼最有可能的就是 hibernate.cfg.xml 中的mapping有問題了,開啟一看,原來被屏蔽了:

我的hibernate.cfg.xml 檔案:

<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">

  <!-- ISessionFactory instance -->
  <session-factory>
    <!-- properties -->
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="show_sql">true</property>
    <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
    <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
    <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=EDP.Website/AppData/BbsData.mdb;Persist Security Info=False</property>
   
    <!--<mapping assembly="EDP.Provider" />-->
   
  </session-factory>
</hibernate-configuration>

把   <mapping assembly="EDP.Provider" /> 行開啟就行了,意思是,映射 EDP.Provider 下的所有類,因為我把資料層和實體類放到一個dll工程 “EDP.Provider” 中了,所以只要指定映射EDP.Provider 下的所有類就OK 了。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.