How to use MySQL database with Orchard CMS 1.3.10?

落爺英雄遲暮 提交于 2019-12-05 08:19:54

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.

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