Nhibernate Exception: Named Query Not Found: storedproceduremaname
Scenario 1: You call a WCF service method to populate a repeater and at page load you are prompted with the above exception.
Resolution for Scenario 1: The above exception appears when Nhibernate doesn’t recognize the entity that you want to call. It could be triggered by multiple causes:
- The stored procedure doesn’t exists in the database;
- The stored procedure is not registered in the .hbm.xml configuration file;
- The mapping assembly for the current business layer is not specified in the web.config file:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="show_sql">true</property> <mapping assembly="MyBusinessNamespace" </mapping>
Check the above list of items on your solution and see if exception disappears.