Home > Blockchain >  Trying to add mutliple params to AddDbContext<T>'s UseSqlServer but can't
Trying to add mutliple params to AddDbContext<T>'s UseSqlServer but can't

Time:11-08

I'm trying to do this:

services.AddDbContext<AppDbContext>(
                opt => opt.UseSqlServer(
                    configuration.GetConnectionString("AppConnectionString"),
                x => x.UseNetTopologySuite(),
                options => options.EnableRetryOnFailure())); // Here's where it fails

But I'm getting this: No overload for method UseSqlServer takes 3 arguments

I understand that however I don't know how to do it any other way besides going down a path I don't know.

CodePudding user response:

You can chain the configuration method calls like so:

x => x.UseNetTopologySuite().EnableRetryOnFailure()

CodePudding user response:

Use the following:

services.AddDbContext<AppDbContext>(
    opt => opt.UseSqlServer(
        configuration.GetConnectionString("AppConnectionString"),
        options => options
            .UseNetTopologySuite()
            .EnableRetryOnFailure()
        )
    ); 
  • Related