Reputation: 81
I have attempted to re-write my DbContext from EF Core to EF6 to work with my supported database by following the following documentation: https://docs.asp.net/en/latest/data/entity-framework-6.html
However I receive the error The name 'Configuration' does not exist in the current context
based on the following line of code in my Startup.cs:
services.AddScoped((_) => new PortalUserContext(Configuration["Data:DefaultConnection:ConnectionString"]));
I have added the System.Configuration.dll to the solution's references which causes a new error 'Configuration' is a type, which is not valid in the given context NextGenPortal
`
Upvotes: 2
Views: 3536
Reputation: 31
I ran into a similar issue when trying to add Configuration to an asp.net core project. I eventually ran into this blog post that explains how to define that Configuration property, which for some strange reason is not covered in the asp.net core documentation.
http://www.mikesdotnetting.com/article/284/asp-net-5-configuration
Basically you need to define this property in your Startup class and then instantiate it in the constructor with the corresponding config file. The article is a bit outdated but it's easier to figure out the parts that changed. Like the signature for the Startup constructor.
Upvotes: 2