HI All,
What are the steps to use NHibernate from the model component of MVC?
HI All,
What are the steps to use NHibernate from the model component of MVC?
the Models folder in ASP.NET MVC should be for View Models (return complex objects to the controler=>view), NHibernate ISessionFactory should be started in the Application_Start event in your global.asax for the MVC project. The Mapping and Entities themselves I would recommend to live in a different project, normally with a combination of folders called Mappings/Domain/Persistence to keep it simple. For a more structured solution I would look at the DDD layers, but that is alot of complexity for small implementations and doesn't works for every project.
Nothing is different you add the hibernate.cfg.xml in the root of the web project and add your mapping files and you are good to go
Have a look at SharpArchitecture, this is best practice for MVC with NHIbernate.