6

Using NHibernate with an ASP.NET MVC 3 Application

Once a company has created a database and the internal systems to control the data, it is not very difficult to use the data again with other functionality. The myGuitarStore database contains information about the types of guitars, the builder, the model, and the cost. Obviously, this information is something a potential customer would like to know before making a purchase. One of the best means of providing this information to a customer is via a website. Therefore, this chapter describes and creates a website that implements ASP.NET MVC 3 using NHibernate.

To create the website shown in Figure 6-1, you will perform the following activities:

  1. Install ASP.NET MVC 3, which deposits the MVC 3 assemblies and registers them into the Global Assembly Cache (GAC).
  2. Add an ASP.NET MVC project to the existing GuitarStore solution.
  3. Configure NHibernate and the Session solution.
  4. Configure the View and Controller.

images

FIGURE 6-1

INSTALLING ASP.NET MVC 3

ASP.NET MVC 3 is not installed with Visual Studio 2010. Therefore, you need to download it from the Microsoft website at www.asp.net/mvc/mvc3 and install it just as you would any other software package. The ASP.NET MVC 3 download used in this example is AspNetMVC3ToolsUpdateSetup.exe.

ADDING AN ASP.NET MVC 3 PROJECT TO THE GUITARSTORE SOLUTION

Open Microsoft Visual Web Developer 2010 Express ...

Get Working with NHibernate 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.