NHibernate official website for Http://nhibernate.info. Official website of documentation, help document the NHibernate Reference (HTML, single page HTML, PDF, CHM), Case tutorial Tutorial:your first NHibernate base D application, these two documents are my main basis for writing this article.
NHibernate is an object/relational database mapping tool for the. NET environment, and the following is an example of MySQL interaction.
C # connects to the MySQL database by writing code that calls the MySQL API to manipulate the MySQL database.
The principle of using nhibernate to interact with MySQL is that writing code calls NHibernate's api,nhibernate calls the MySQL API to manipulate the MySQL database.
1. Add a dynamic link library
(1) Add nhibernate dynamic link library
Method One: In the project (right-click)-Manage NuGet packages (N) and then search for nhibernate in the browser and install
Method Two: In NHibernate official website: http://nhibernate.info Click Download Now NH5.0.3 download and add \required_bins\nhibernate.dll to the reference
(2) Add a MySQL dynamic link library
Method One: In the project (right-click)-Manage the NuGet package (N) and then search for mysql.data inside the browser and install it.
Method Two: Install the database MySQL to select Connector.net 6.9 installation, will C:\Program Files (x86) \mysql\connector.net 6.9\ A reference to a project that is added to the MySql.Data.dll in assemblies v4.0 or v4.5. V4.0 and v4.5, corresponding to the version number of the. NET framework in the Visual Studio specific project properties-application-target framework.
Using NHibernate to interact with MySQL