- **ABP Framework version: latest
- UI type: MVC
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): yes
Hi,
Can you please point me in the correct direction to how to configure the database connection string to load from a Key Vault scret (Azure). The part that is causing me the most confusion is how to set the connection string from the Config that is loading from key vault.
I have Configured the Program.cs in the Web project to load settings from kv.
And I have tested to make sure it grabs the values from kv, which seem to be fine.
Lets assume I have a secret called db-string and i want to set the DbConext connection string to that value. How do to get the DbContext to use this connection string?
Regards John
4 Answer(s)
-
0
Hi @jtallon, You can refer to https://docs.microsoft.com/en-us/aspnet/core/security/key-vault-configuration?view=aspnetcore-5.0#bind-an-array-to-a-class, I think only need to define
ConnectionStrings--db-string
. -
0
Thanks for your help @Moyaoxiang, that clears a lot up.
How can I configure the DbContext to use a specific database connection string config name. By default it used "Default", but I want to tell it to use "Somethingelse" at run time. Not sure of this is an abp config or ef config.
-
0
Hi jtallon, You can use the
ConnectionStringName
Attribute. e.g.[ConnectionStringName("Default")] public class CommercialDemoDbContext : AbpDbContext<CommercialDemoDbContext> { }
-
0
This question has been automatically marked as stale because it has not had recent activity.