{"action":"created","issue":{"url":"https://api.github.com/repos/SharpRepository/SharpRepository/issues/189","repository_url":"https://api.github.com/repos/SharpRepository/SharpRepository","labels_url":"https://api.github.com/repos/SharpRepository/SharpRepository/issues/189/labels{/name}","comments_url":"https://api.github.com/repos/SharpRepository/SharpRepository/issues/189/comments","events_url":"https://api.github.com/repos/SharpRepository/SharpRepository/issues/189/events","html_url":"https://github.com/SharpRepository/SharpRepository/issues/189","id":295871452,"number":189,"title":"AutoFac InstancePerRequest() doesn't work","user":{"login":"GiganteX","id":15637533,"avatar_url":"https://avatars3.githubusercontent.com/u/15637533?v=4","gravatar_id":"","url":"https://api.github.com/users/GiganteX","html_url":"https://github.com/GiganteX","followers_url":"https://api.github.com/users/GiganteX/followers","following_url":"https://api.github.com/users/GiganteX/following{/other_user}","gists_url":"https://api.github.com/users/GiganteX/gists{/gist_id}","starred_url":"https://api.github.com/users/GiganteX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GiganteX/subscriptions","organizations_url":"https://api.github.com/users/GiganteX/orgs","repos_url":"https://api.github.com/users/GiganteX/repos","events_url":"https://api.github.com/users/GiganteX/events{/privacy}","received_events_url":"https://api.github.com/users/GiganteX/received_events","type":"User","site_admin":false},"labels":[{"id":6141566,"url":"https://api.github.com/repos/SharpRepository/SharpRepository/labels/duplicate","name":"duplicate","color":"cccccc","default":true},{"id":52710014,"url":"https://api.github.com/repos/SharpRepository/SharpRepository/labels/help","name":"help","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-02-09T13:30:15Z","updated_at":"2018-02-10T16:58:29Z","closed_at":null,"author_association":"NONE","body":"This works:\r\nbuilder.RegisterType<MyDbContext>().As<DbContext>();\r\nBut memory usage keeps increasing until out of memory, GC doesn't flush fast enough.\r\n\r\nI want to create a new MyDbContext for every request (it's a REST api) to make sure the used ones are disposed ASAP.\r\n\r\nSeems like this should do the trick, but when I use it the AutoFac fails to resolve the dbcontext:\r\nbuilder.RegisterType<MyDbContext>().As<DbContext>().InstancePerRequest();\r\n\r\nIf I do this it works for one call, on the second it complains that the dbcontext is disposed....\r\nbuilder.RegisterType<MyDbContext>().As<DbContext>().InstancePerLifetimeScope();\r\n\r\nWhat could be wrong?"},"comment":{"url":"https://api.github.com/repos/SharpRepository/SharpRepository/issues/comments/364671804","html_url":"https://github.com/SharpRepository/SharpRepository/issues/189#issuecomment-364671804","issue_url":"https://api.github.com/repos/SharpRepository/SharpRepository/issues/189","id":364671804,"user":{"login":"GiganteX","id":15637533,"avatar_url":"https://avatars3.githubusercontent.com/u/15637533?v=4","gravatar_id":"","url":"https://api.github.com/users/GiganteX","html_url":"https://github.com/GiganteX","followers_url":"https://api.github.com/users/GiganteX/followers","following_url":"https://api.github.com/users/GiganteX/following{/other_user}","gists_url":"https://api.github.com/users/GiganteX/gists{/gist_id}","starred_url":"https://api.github.com/users/GiganteX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GiganteX/subscriptions","organizations_url":"https://api.github.com/users/GiganteX/orgs","repos_url":"https://api.github.com/users/GiganteX/repos","events_url":"https://api.github.com/users/GiganteX/events{/privacy}","received_events_url":"https://api.github.com/users/GiganteX/received_events","type":"User","site_admin":false},"created_at":"2018-02-10T16:58:29Z","updated_at":"2018-02-10T16:58:29Z","author_association":"NONE","body":"Omar, \r\n\r\nI started by looking into these suggestions  to get it working with Autofac [https://github.com/SharpRepository/SharpRepository/issues/93]( #93) but did not get it to work. I got the \"There is no DependencyResolver.Current\" problem.\r\n\r\nSo I tried StructureMap, and BAM that just worked out of the box, no tricky configuration issues like I had with Autofac! A bit surprised but pleasantly so. I just added the DbContextRegistrry class and the ForRepositoreuesUseSharpRepository line and that was it!\r\n\r\nBut what about the InstancePerRequest thing? Does StructureMap handle that by default ie it doesn't reuse the dbcontext for every call like Autofac does? Because that's the critical point,  I want it to dispose the dbcontext for every new call so the IIS server doesn't run out of memory...\r\n\r\nOh and I noticed SharpRepository 2.02 is out of the alpha/beta! Very interesting. And the repository.json is now used for non-Core projects also. Well, why not!"}}
{"actor":{"display_login":"GiganteX"}}