You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But when I want to use the part of Configuration.GetConnectionString, I get a red line under saying: "The name "Configuration does not exist in current context"
Please help! (see attached file below)
The text was updated successfully, but these errors were encountered:
Basically, we create a private variable of type IConfiguration, then we create a constructor for the Startup class with injection of an IConfiguration object, then pass the created object to the private IConfiguration variable we just created.
Why the book does not explain this?
sipi41
changed the title
Am I doing something wrong?
Configuration does not exist in current context Core 2.0
Feb 12, 2018
I've only had this issue arise (adding the DI of an IConfiguration object into the Startup class) when starting from an Empty project with no scaffolding (API or MVC Core 2.x).
Thank you sipi41 for coming back and answering this.
In the first example of the book, it is instructed to do the following:
public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddDbContext<BlogContext>(options => options.UseSqlServer(Configuration.GetConnectionString(" DefaultConnection"))); services.AddMvc(); }
But when I want to use the part of Configuration.GetConnectionString, I get a red line under saying: "The name "Configuration does not exist in current context"
Please help! (see attached file below)
The text was updated successfully, but these errors were encountered: