0

Error snippet in Visual studio:

Error snippet in Visual studio

GetConnectionString parameter error ASP.NET Core 6.0

Error CS7036 There is no argument given that corresponds to the required formal parameter 'name' of 'ConfigurationExtensions.GetConnectionString(IConfiguration, string)'

4
  • Add Microsoft.Extensions.Configuration.Abstractions package to project Commented Dec 20, 2021 at 11:17
  • its not helping, still the same error though, the error shown is about parameters of the getconnectionstring method Commented Dec 20, 2021 at 11:23
  • Does this answer your question? ASP.NET Core 6 how to access Configuration during setup Commented Dec 20, 2021 at 15:49
  • Ok, you are right. I misinterpreted the question Commented Dec 21, 2021 at 6:53

1 Answer 1

1

You can use this sample:

var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<ApplicationDbContext>(optionsBuilder => optionsBuilder.UseSqlServer(connectionString));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.