How to use MySQL database with Orchard CMS 1.3.10?
Asked Answered
A

1

6

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.

Agony answered 2/1, 2012 at 12:46 Comment(0)
C
4

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.

Chenille answered 3/1, 2012 at 9:33 Comment(1)
Thanks but i missed to inform here that i got that part to work but now i have another problem, take a look at the url if you know anything: orchard.codeplex.com/discussions/284811Agony

© 2022 - 2024 — McMap. All rights reserved.