views:

89

answers:

3

HI All,

What are the steps to use NHibernate from the model component of MVC?

+1  A: 

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.

F.Aquino
A: 

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

Yassir
A: 

Have a look at SharpArchitecture, this is best practice for MVC with NHIbernate.

http://code.google.com/p/sharp-architecture/

Burt