{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5385","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5385/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5385/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5385/events","html_url":"https://github.com/aspnet/EntityFramework/issues/5385","id":155302132,"number":5385,"title":"No database provider has been configured for this DbContext.","user":{"login":"ElioBatista","id":451446,"avatar_url":"https://avatars.githubusercontent.com/u/451446?v=3","gravatar_id":"","url":"https://api.github.com/users/ElioBatista","html_url":"https://github.com/ElioBatista","followers_url":"https://api.github.com/users/ElioBatista/followers","following_url":"https://api.github.com/users/ElioBatista/following{/other_user}","gists_url":"https://api.github.com/users/ElioBatista/gists{/gist_id}","starred_url":"https://api.github.com/users/ElioBatista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElioBatista/subscriptions","organizations_url":"https://api.github.com/users/ElioBatista/orgs","repos_url":"https://api.github.com/users/ElioBatista/repos","events_url":"https://api.github.com/users/ElioBatista/events{/privacy}","received_events_url":"https://api.github.com/users/ElioBatista/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-05-17T16:21:02Z","updated_at":"2016-05-24T00:14:55Z","closed_at":null,"body":"After replacing EF Core rc 1 with EF Core rc 2 final,  We are getting an invalid operation exception when calling GetService() method bellow, the full message:\r\n\r\n> No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.\r\n\r\n```\r\npublic static ObservableCollection<TEntity> Local<TEntity>(this DbSet<TEntity> set)\r\n            where TEntity : class\r\n{\r\n            var context = set.GetService<DbContext>();\r\n            ...\r\n}\r\n```\r\n\r\nWe effectively are setting the database provider in OnConfiguring:\r\n\r\n        protected override void OnConfiguring(DbContextOptionsBuilder builder)\r\n        {\r\n            base.OnConfiguring(builder);\r\n            var connStringBuilder = new SqlConnectionStringBuilder();\r\n            connStringBuilder.UserID = \"MyUserID\";\r\n            ...         \r\n            builder.UseSqlServer(connStringBuilder.ConnectionString);\r\n        }\r\n\r\nSo it seems that the issue comes from the method GetService() not resolving the correct DbContext instance for the given DbSet.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/221132678","html_url":"https://github.com/aspnet/EntityFramework/issues/5385#issuecomment-221132678","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5385","id":221132678,"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-05-24T00:14:55Z","updated_at":"2016-05-24T00:14:55Z","body":"Note for triage: I would have expected `context.GetService<DbContext>();` to have thrown because `DbContext` is not registered in the container, but it still throws the \" No database provider has been configured\" exception."}}
{"actor":{"display_login":"rowanmiller"}}