Ric*_*rdP 6 mysql orchardcms asp.net-mvc-3
我正在尝试更改Orchard.Setup模块,以便我可以使用MySQL作为数据安装Orchard CMS 1.3.10.
我来了这么久,我在GUI中安装MySQL进行设置,当我按下设置按钮时,我收到来自果园的错误消息:
The value 'MySql' is not valid for DatabaseOptions.
Run Code Online (Sandbox Code Playgroud)
但是我无法找到我如何将MySql添加为DatabaseOptions,还有其他人让它与MySQL一起工作吗?
用于MySQL的旧模块与Orchard CMS的最新版本不兼容,这就是为什么它由我自己制作它,如果我让它工作我将发布它供其他人使用的开放源代码.
您所讨论的错误是因为 DatabaseOptions 属性是布尔值。您需要更改该属性以接受字符串值。设置控制器中有几个地方需要更改该属性的使用方式......
然而,最重要的部分是实现 DataServicesProvider。我将我的添加到核心中,但我认为您可以将其作为一项功能放入设置模块中。我的看起来像这样...
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
哦,不要忘记您需要引用 MySql.Data。它以 NuGet 包的形式提供。