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 have come so long that I get MySQL in the GUI for tuning, and when I click the settings button, I get this error message from the garden:

The value 'MySql' is not valid for DatabaseOptions. 

But I can not find how I am adding MySql as DatabaseOptions, can anyone else make it work with MySQL?

The old module for MySQL is not compatible with the latest version of Orchard CMS, so it calls to do it on its own, if I earn it, I am going to release it with open source code for other users.

+6
source share
1 answer

The error you are talking about is because the DatabaseOptions property is a boolean. You will need to change this property to accept string values. There are several places in the installation controller that you need to change how this property is used ...

However, the most important part is the implementation of DataServicesProvider. I added my kernel, but I think you could just put it in the installation module as a function. 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 that you will need to reference MySql.Data. It is available as a NuGet package.

+4
source

Source: https://habr.com/ru/post/904898/


All Articles