OrchardCore.Samples icon indicating copy to clipboard operation
OrchardCore.Samples copied to clipboard

How to configure the connection string for all functions of a single tenant?

Open china-live opened this issue 6 years ago • 1 comments

china-live avatar May 14 '18 19:05 china-live

@china-live if you are still interested in this please take a look at the "OrchardCore" section https://github.com/OrchardCMS/OrchardCore.Samples/blob/master/MultiTenantApplication/appsettings.json and how it has CustomTitle and CustomSetting properties. Then take a look at https://github.com/OrchardCMS/OrchardCore.Samples/blob/master/MultiTenantApplication/Pages/Index.cshtml and how ShellSettings is injected into the view and used to access the values of CustomTitle and CustomSetting on a per-tenant basis.

In the same way you could have a MyConnectionString property in each tenant and then inject the ShellSetting into your a scoped data access layer (a subclass of DbContext for example) and use that to establish the connection string. How that is done is specific to your data access layer. If you are using EF Core try google "ef core onconfiguring connection string" to get some ideas of how to do that.

jeremycook avatar Oct 04 '19 14:10 jeremycook