Even though SQLServer is the common standard when deploying .NET applications, sometimes when developing for a shared hosting environment MySql is preferable as it's often cheaper and more widely available.
With this in mind we've decided to add support for running Piranha on MySql in the upcoming 1.1.2 version. By implementing this functionality we also hope that we're opening up the door for developers wanting to run and deploy a Piranha application in a Mono environment on a non Microsoft OS. In this post we'll show how to configure your Piranha application for MySql.
Note that the following functionality has not yet been released through NuGet. To utilize it you'll have to download the latest source code from GitHub and compile the libraries on your local machine. The functionality is in beta, so if you run into bugs or issues, please report them in the issue list at GitHub.
Getting the MySql connector
The MySql connector is available here from the official MySql homepage. From this page you can download both source code packages for Visual Studio as well as precompiled binaries for .NET and Mono. In our example we've simply downloaded the binaries available for .NET & Mono for version 6.5.4.
After you've downloaded and unzipped the package, copy the following dll's into the Bin directory of you Piranha website.
Setting up the DbProviderFactory
As Piranha uses the basic .NET DbProviderFactory for creating it's connections, configuration is just a matter of setting up the right provider in the Web.config file of your application. Add the following lines of code in the configuration section of your web.config for version 6.5.4 of the MySql connector. If you're using a different version the Version and PublicKeyToken will differ.
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=220.127.116.11, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
Setting up the connection string
The following syntax applies for setting up the connection string for MySql.
<add name="piranha" connectionString="server=...;database=...;uid=...;pwd=..."
Installing the website
Apart from this configuration everything should run smoothly and when your start your Piranha application for the first time you should be redirected to the install view.
blog comments powered by Disqus