Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new database provider (Oracle) #1325

Open
jpiquot opened this issue Dec 28, 2017 · 10 comments
Open

Add new database provider (Oracle) #1325

jpiquot opened this issue Dec 28, 2017 · 10 comments
Milestone

Comments

@jpiquot
Copy link
Contributor

jpiquot commented Dec 28, 2017

Hi,
I need to add a new database provider for oracle databases but it seems that the store initialization is hardcoded. I can add a new provider but it will result in a store initialization error.

Could we put the initialization code as part of the DataProvider so the Store initialization uses it ?

Regards,
Jérôme Piquot
Flexmind France

OrchardCore.Data.ServiceCollectionExtensions.cs :
       public static IServiceCollection AddDataAccess(this IServiceCollection services)
        {
            services.AddScoped<IDataMigrationManager, DataMigrationManager>();
            services.AddScoped<IModularTenantEvents, AutomaticDataMigrations>();

            // Adding supported databases
            services.TryAddDataProvider(name: "Sql Server", value: "SqlConnection", hasConnectionString: true);
            services.TryAddDataProvider(name: "Sqlite", value: "Sqlite", hasConnectionString: false);
			services.TryAddDataProvider(name: "MySql", value: "MySql", hasConnectionString: true);
			services.TryAddDataProvider(name: "Postgres", value: "Postgres", hasConnectionString: true);

			// Configuring data access

	   services.AddSingleton<IStore>(sp =>
            {
                var shellSettings = sp.GetService<ShellSettings>();

                if (shellSettings.DatabaseProvider == null)
                {
                    return null;
                }
                
                var storeConfiguration = new Configuration();

                // Disabling query gating as it's failing to improve performance right now
                storeConfiguration.DisableQueryGating();

                switch (shellSettings.DatabaseProvider)
                {
                    case "SqlConnection":
                        storeConfiguration.UseSqlServer(shellSettings.ConnectionString, IsolationLevel.ReadUncommitted);
                        break;
                    case "Sqlite":
                        var shellOptions = sp.GetService<IOptions<ShellOptions>>();
                        var option = shellOptions.Value;
                        var databaseFolder = Path.Combine(option.ShellsApplicationDataPath, option.ShellsContainerName, shellSettings.Name);
                        var databaseFile = Path.Combine(databaseFolder, "yessql.db");
                        Directory.CreateDirectory(databaseFolder);
                        storeConfiguration.UseSqLite($"Data Source={databaseFile};Cache=Shared", IsolationLevel.ReadUncommitted);
                        break;
					case "MySql":
                        storeConfiguration.UseMySql(shellSettings.ConnectionString, IsolationLevel.ReadUncommitted);
						break;
					case "Postgres":
                        storeConfiguration.UsePostgreSql(shellSettings.ConnectionString, IsolationLevel.ReadUncommitted);
                        break;
					default:
                        throw new ArgumentException("Unknown database provider: " + shellSettings.DatabaseProvider);
                }

@sebastienros
Copy link
Member

I would suggest that we try refactor this code to make it extensible. When we manage to move at least one in an external module (as a test) then this issue should be fixed. It will require YesSql to have an Oracle provider first.

@sebastienros sebastienros added this to the backlog milestone Jan 4, 2018
@jpiquot
Copy link
Contributor Author

jpiquot commented Jan 5, 2018

Hi Sebastien,
Yes, I was thinking that the provider would not be too much work as YesSql uses Dapper that supports Oracle. The only issue is that there is no official .Net Core provider for Oracle. I have too options:

  1. Use OrchardCore targetting net461
  2. Use a third party .Net Core Oracle Provider
    I will try next week all these.

@hishamco
Copy link
Member

hishamco commented Jan 5, 2018

Adding Oracle to YesSql & thinking about database extensibility here may allow things much easier

@hishamco
Copy link
Member

Related to this sebastienros/yessql#81

@pbros
Copy link
Contributor

pbros commented Apr 9, 2019

Hello,

I have been evaluating Orchard Core, but would like to use Oracle DB.

Oracle has released a provider for .NET Core (https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core/2.18.6), and also a EntityFramework provider (currently still in Beta) (https://www.nuget.org/packages/Oracle.EntityFrameworkCore/2.18.0-beta3)

Have there been any updates for supporting Oracle?

Thank you

@hishamco
Copy link
Member

hishamco commented Apr 9, 2019

IMHO we should wait until the RTM release

@pbros
Copy link
Contributor

pbros commented Apr 10, 2019

Hi @hishamco does Orchard use Entity Framework? If so I agree, but if not, the Oracle.ManagedDataAccess.Core is an RTM release. I was in beta earlier last year.

@Jetski5822
Copy link
Member

Jetski5822 commented Apr 10, 2019 via email

@hishamco
Copy link
Member

I think we need to close this issue, and better track it in YesSql sebastienros/yessql#81

@Piedone
Copy link
Member

Piedone commented May 20, 2020

This can be left open so once the YesSQL issue is resolved we can continue with this one. However, I think Oracle DB support at most can be on some best effort basis, not on part with the other providers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants