How to use MySQL database with Orchard CMS 1.3.10?

孤人 提交于 2019-12-07 03:40:03

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8701008/how-to-use-mysql-database-with-orchard-cms-1-3-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!