Sharp Architecture and specifically NHibernate can be setup to work with most of the databases out there. The Nhibernate.config file comes setup to work with SQL Server out-of-the-box. Setting up NHibernate to work with MySql is not difficult. MySql database server provides a robust solution to any application and good savings compared to other databases, many hosts like GoDaddy or FatCow provide cheap alternatives to hosting and many plans with unlimited MySql Databases. Follow this steps to setup MySql in Sharp Architecture using NHibernate:
- Download Connector-Net 6.2.2 from “http://dev.mysql.com/downloads/connector/net/”
- Unzip and run “mysql.data.msi” to install.
- After installation is completed, you can find the required DLLs in the default directory: C:\Program Files\MySQL\MySQL Connector Net 6.2.2\Assemblies
- Open NHibernate.config from your project and change the following:
- “connection.driver_class” property value : change “NHibernate.Driver.SqlClientDriver” to “NHibernate.Driver.MySqlDataDriver“
- “dialect” property value : change “NHibernate.Dialect.MsSql2005Dialect” to “NHibernate.Dialect.MySQLDialect“
- Change “connection.connection_string” to your MySql database settings.
EX: Data Source=localhost;Database=MyDB;UID=myUser;pwd=7HYSAYG2;
- Copy Assemblies: “MySql.Data.dll” and “MySql.Web.dll” from C:\Program Files\MySQL\MySQL Connector Net 6.2.2\Assemblies to your local “lib” folder in your project.
- Add as references to your {projectName}.Web project. Once added, right click to get to Properties and make sure “Copy Local” is set to TRUE for both Dlls.