Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MySQL database with Orchard CMS 1.3.10?

I am trying to change the Orchard.Setup module so i can install Orchard CMS 1.3.10 with MySQL as datase.

I come so long that i getting MySQL in the GUI for setup and when i press setup button i getting this error message from orchard:

The value 'MySql' is not valid for DatabaseOptions.

But i can not find how i adding MySql as DatabaseOptions, do anyone else get it to work with MySQL?

The old module for MySQL is not compatible wtih the latest version of Orchard CMS thats why it ring to make it by my own, if i get it to work i going to release it open source for others to use.

like image 349
RickardP Avatar asked Jan 02 '12 12:01

RickardP


1 Answers

The error you're talking about is because the DatabaseOptions property is a boolean. You'll need to change that property to accept string values. There are a few places in the Setup Controller that you'll need to change how that property is used...

However, the most important part is to implement a DataServicesProvider. I added mine to core, but I think you could just put it in the Setup Module as a feature. Mine looks like this...

namespace Orchard.Data.Providers {
    public class MySqlDataServiceProvider : AbstractDataServicesProvider
    {
        private readonly string _connectionString;

        public MySqlDataServiceProvider(string dataFolder, string connectionString)
        {
            _connectionString = connectionString;
        }

        public static string ProviderName
        {
            get { return "MySql"; }
        }

        public override IPersistenceConfigurer GetPersistenceConfigurer(bool createDatabase)
        {
            var persistence = MySQLConfiguration.Standard;

            if (string.IsNullOrEmpty(_connectionString))
            {
                throw new ArgumentException("The connection string is empty");
            }

            persistence = persistence.ConnectionString(_connectionString);
            return persistence;
        }
    }
}

Oh, and don't forget you'll need to reference MySql.Data. It's available as a NuGet package.

like image 141
Brandon Joyce Avatar answered Nov 10 '22 05:11

Brandon Joyce