Starts in:
1 DAY
9 HRS
22 MIN
0 SEC
Starts in:
1 D
9 H
22 M
0 S
Open Closed

Question on DBMigrator project's connection string (appsettings.json) #4571


User avatar
0
balessi75 created

ABP 7.0.1 Commercial / Blazor Server / EF / Separated Tenant and Host DBs / Non-tiered

Hi,

In order for developers to use local DBs without their local DB references being checked into source control, we attempted to use .NET's 'Manage User Secrets' feature for the DBMigrator project (secrets.json).

We are finding though that the framework still uses the connection string under the standard appsettings.json file for the DBMigrator project. When using the secrets.json feature under the Blazor project, everything works as expected. Is this by design or is there something we are missing with regards to the DBMigrator project?

Thanks in advance,

-Brian


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try to find the MyProjectNameDbContextFactory and add .AddAppSettingsSecretsJson() after .AddJsonFile("appsettings.json", optional: false)

  • User Avatar
    0
    balessi75 created

    Hi @liangshiwei,

    AddAppSettingsSecretsJson() is not a method of IConfigurationBuilder, so the change to DbContextFactory didn't work for us.

    FYI - Instead, we got it to work by adding the following to the CreateHostBuilder method of Program.cs in the DbMigrator project.

      .ConfigureAppConfiguration((hostContext, builder) =>
                {
                    if (hostContext.HostingEnvironment.IsDevelopment())
                    {
                        builder.AddUserSecrets<Program>();
                    }
                })
               
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Sorry I thought you were talking appsettings.secrets.json

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06