{"action":"opened","issue":{"url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/7","labels_url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/7/comments","events_url":"https://api.github.com/repos/structuremap/structuremap.dnx/issues/7/events","html_url":"https://github.com/structuremap/structuremap.dnx/issues/7","id":127021197,"number":7,"title":"StructureMap Profiles in DNX only honoured on first request","user":{"login":"benfoster","id":827305,"avatar_url":"https://avatars.githubusercontent.com/u/827305?v=3","gravatar_id":"","url":"https://api.github.com/users/benfoster","html_url":"https://github.com/benfoster","followers_url":"https://api.github.com/users/benfoster/followers","following_url":"https://api.github.com/users/benfoster/following{/other_user}","gists_url":"https://api.github.com/users/benfoster/gists{/gist_id}","starred_url":"https://api.github.com/users/benfoster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benfoster/subscriptions","organizations_url":"https://api.github.com/users/benfoster/orgs","repos_url":"https://api.github.com/users/benfoster/repos","events_url":"https://api.github.com/users/benfoster/events{/privacy}","received_events_url":"https://api.github.com/users/benfoster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-16T12:27:25Z","updated_at":"2016-01-16T12:27:25Z","closed_at":null,"body":"I'm working on adding multi-tenant support to ASP.NET 5 and part of this involves overriding how `IServiceScope` is created.\r\n\r\nWe want to allow dependencies to be overridden for specific tenants and are using StructureMap profiles to do this.\r\n\r\nI've taken the implementation of `IServiceScopeFactory` in this library and changed it to use a profile to create the request container:\r\n\r\n        public IServiceScope CreateScope()\r\n        {\r\n            var profile = Container.GetProfile(\"TestProfile\");\r\n            return new StructureMapServiceScope(profile.GetNestedContainer());\r\n        }\r\n\r\nEverything else is pretty much the same. Unfortunately as you can see from this [repro](https://github.com/benfoster/StructureMapDnxProfileRepro) my profile configured dependency is only used on the first request - in this example we get `Guid.Empty` returned in the output and then it reverts back to the default implementation (returns `Guid.NewGuid()).\r\n\r\nPerhaps I've misunderstood profiles in StructureMap (or DI in ASP.NET 5)?"}}