{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4339","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4339/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4339/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4339/events","html_url":"https://github.com/aspnet/EntityFramework/issues/4339","id":127578544,"number":4339,"title":"An attempt was made to use the context while it is being configured. A DbContext instance cannot be used inside OnConfiguring since it is still being configured at this point.","user":{"login":"valcs007","id":6827384,"avatar_url":"https://avatars.githubusercontent.com/u/6827384?v=3","gravatar_id":"","url":"https://api.github.com/users/valcs007","html_url":"https://github.com/valcs007","followers_url":"https://api.github.com/users/valcs007/followers","following_url":"https://api.github.com/users/valcs007/following{/other_user}","gists_url":"https://api.github.com/users/valcs007/gists{/gist_id}","starred_url":"https://api.github.com/users/valcs007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valcs007/subscriptions","organizations_url":"https://api.github.com/users/valcs007/orgs","repos_url":"https://api.github.com/users/valcs007/repos","events_url":"https://api.github.com/users/valcs007/events{/privacy}","received_events_url":"https://api.github.com/users/valcs007/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-20T01:06:11Z","updated_at":"2016-02-01T19:49:14Z","closed_at":"2016-02-01T19:49:14Z","body":"I am trying to use DI for my dbContext with MVC6/EF7 RC1.\r\n\r\nI am instantiating my ContextTest (inherited from dbcontext) using [FromServices] attribute in the constructor of my TestService class\r\n\r\nSample code:\r\n\r\n```\r\n[FromServices]\r\npublic ContextTest  _testContext { get; set; }\r\n\r\npublic TestService(ContextTest  testContext)\r\n{\r\n_testContext  = testContext;\r\n}\r\n\r\npublic async GetData()\r\n{\r\nawait _testContext.GetFunA();\r\nawait _testContext.GetFunB();\r\nawait _testContext.GetFunC();\r\n}\r\n```\r\n\r\nStartup.cs\r\n\r\n```\r\n services.AddEntityFramework()\r\n                .AddSqlServer()\r\n                .AddDbContext<ContextTest  >(options => options.UseSqlServer(connection))\r\n```\r\n\r\nException:\r\n\r\nSporadically i am running into below exception\r\n\r\n> \"An attempt was made to use the context while it is being configured. A DbContext instance cannot be used inside OnConfiguring since it is still being configured at this point.\"\r\n\r\nMy 2 cents: Something to with Async calls (DI injects only 1 instance and i am trying to fire 3 queries in parallel.\r\n\r\nAny suggestions?"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/178155140","html_url":"https://github.com/aspnet/EntityFramework/issues/4339#issuecomment-178155140","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4339","id":178155140,"user":{"login":"rowanmiller","id":4741851,"avatar_url":"https://avatars.githubusercontent.com/u/4741851?v=3","gravatar_id":"","url":"https://api.github.com/users/rowanmiller","html_url":"https://github.com/rowanmiller","followers_url":"https://api.github.com/users/rowanmiller/followers","following_url":"https://api.github.com/users/rowanmiller/following{/other_user}","gists_url":"https://api.github.com/users/rowanmiller/gists{/gist_id}","starred_url":"https://api.github.com/users/rowanmiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rowanmiller/subscriptions","organizations_url":"https://api.github.com/users/rowanmiller/orgs","repos_url":"https://api.github.com/users/rowanmiller/repos","events_url":"https://api.github.com/users/rowanmiller/events{/privacy}","received_events_url":"https://api.github.com/users/rowanmiller/received_events","type":"User","site_admin":false},"created_at":"2016-02-01T19:49:14Z","updated_at":"2016-02-01T19:49:14Z","body":"Closing as we have not heard back"}}