Add IntelliSense To Mapping File



In this chapter, we will add IntelliSense to our NHibernate mapping files (*.hbm.xml files). As you have observed while mapping the domain Student class that currently we don’t have IntelliSense available. It’s very useful to have the XML schemas available. So in this chapter you will understand how to add IntelliSense in Visual Studio for these NHibernate XML files.

Open the mapping file and you will see that XML menu option appears in the main menu.

XML Menu

Select the XML → Schemas… menu option and it will display the XML Schemas dialog box.

XML Schemas

Select the Add… button which is on the top right of the dialog box, which opens the file dialog. Now go to the packages folder, which is in the Solution folder of your project and you will see the different packages included in your project.

Packages Folder

Now, double-click on NHibernate.4.*** folder and you will see the two schemas (*.xsd) files or XML schema definition files that define the NHibernate configuration and mapping.

Nhibernate Configuration

Select these two schema files and click Open button.

Two Schema Files

You can see that the NHibernate schemas are added into the XML Schemas dialog. Click the OK button. Now, let’s start a new property tag and you will see that we've got full IntelliSense on here.

IntelliSense

IntelliSense is now available for you which saves a lot of time during object-relational mapping.

Advertisements