I was messing around with EntityFramework 7 and ASP.NET 5 / vNext. I follow this tutorial . However, I ran into a problem when I try to get the connection string from the config.json file:
'IConfiguration' does not contain a definition for 'Get' and no extension method 'Get' accepting a first argument of type 'IConfiguration' could be found (are you missing a using directive or an assembly reference?)
I don’t think I am missing the link, but here is the project.json dependency section:
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"System.Net.Http": "4.0.0-beta-23019",
"Microsoft.AspNet.WebApi": "5.2.3",
"Microsoft.AspNet.WebUtilities": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Owin.Security": "3.0.1",
"Microsoft.AspNet.Hosting": "1.0.0-beta5",
"Kestrel": "1.0.0-*",
"Microsoft.AspNet.WebApi.Owin": "5.2.3",
"Microsoft.Owin.Security.OAuth": "3.0.1",
"Microsoft.AspNet.Mvc.Core": "6.0.0-beta5",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta5",
"Microsoft.AspNet.Identity.Owin": "2.2.1",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5",
"EntityFramework.SqlServer": "7.0.0-beta8-15186",
"EntityFramework.Commands": "7.0.0-beta5",
"Microsoft.AspNet.Http.Abstractions": "1.0.0-beta8-15078",
"Microsoft.Framework.Logging.Console": "1.0.0-beta8-15086"
}
Here is the code causing the problem (in Startup.cs):
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<RibandelleDbContext>(options =>
{
options.UseSqlServer(Configuration.Get("Data:ConnectionString"));
});
}
The bit Configuration.Get("Data:ConnectionString")returns the error above. I did my best to compare the code with the sample documentation, and it seems to me completely identical. I cannot figure out where the Get () method comes from.
How can I correctly understand what I am missing?