0

I've updated to linq2db 5.0 and when I try to execute it I got the error ': 'Invalid configuration. Configuration string is not provided.' '

Here's my configuration

public static void RegisterLinq2DbConnection(this IFunctionsHostBuilder builder)
{
    var connectionString = Environment.GetEnvironmentVariable("ConnectionString");
    //using LinqToDB.AspNet
    builder.Services.AddLinqToDBContext<AppDataConnection>((provider, options) =>
    {
        options
            .UseSqlServer(connectionString)
            .UseDefaultLogging(provider);

        return options;
    });

    builder.Services.AddScoped<ITTGRepository, TTGRepository>();
}

and here's the AppConnection

public class AppDataConnection : DataConnection
{
    public AppDataConnection(DataOptions options)
        : base(options)
    {
    }
}

But in the config step I got the connection string valorized.. any suggestion? I've followed the update guide on linq2db page.

Thanks

Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32
advapi
  • 3,661
  • 4
  • 38
  • 73

1 Answers1

0

DataOptions are immutable and you have to return newly created options when configuring context.

//using LinqToDB.AspNet
builder.Services.AddLinqToDBContext<AppDataConnection>((provider, options) =>
{
    return options
        .UseSqlServer(connectionString)
        .UseDefaultLogging(provider);
});
Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32