{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4265","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4265/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4265/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4265/events","html_url":"https://github.com/aspnet/EntityFramework/pull/4265","id":125723548,"number":4265,"title":"Adds and implements ModelCustomizer","user":{"login":"Grinderofl","id":499143,"avatar_url":"https://avatars.githubusercontent.com/u/499143?v=3","gravatar_id":"","url":"https://api.github.com/users/Grinderofl","html_url":"https://github.com/Grinderofl","followers_url":"https://api.github.com/users/Grinderofl/followers","following_url":"https://api.github.com/users/Grinderofl/following{/other_user}","gists_url":"https://api.github.com/users/Grinderofl/gists{/gist_id}","starred_url":"https://api.github.com/users/Grinderofl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Grinderofl/subscriptions","organizations_url":"https://api.github.com/users/Grinderofl/orgs","repos_url":"https://api.github.com/users/Grinderofl/repos","events_url":"https://api.github.com/users/Grinderofl/events{/privacy}","received_events_url":"https://api.github.com/users/Grinderofl/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-09T00:31:22Z","updated_at":"2016-01-13T00:43:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/aspnet/EntityFramework/pulls/4265","html_url":"https://github.com/aspnet/EntityFramework/pull/4265","diff_url":"https://github.com/aspnet/EntityFramework/pull/4265.diff","patch_url":"https://github.com/aspnet/EntityFramework/pull/4265.patch"},"body":"Provides a possible implementation for a way to alter modelbuilder from outside dbcontext.\r\nResolves: #2992 and #2805 "},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/171112629","html_url":"https://github.com/aspnet/EntityFramework/pull/4265#issuecomment-171112629","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/4265","id":171112629,"user":{"login":"AndriySvyryd","id":6539701,"avatar_url":"https://avatars.githubusercontent.com/u/6539701?v=3","gravatar_id":"","url":"https://api.github.com/users/AndriySvyryd","html_url":"https://github.com/AndriySvyryd","followers_url":"https://api.github.com/users/AndriySvyryd/followers","following_url":"https://api.github.com/users/AndriySvyryd/following{/other_user}","gists_url":"https://api.github.com/users/AndriySvyryd/gists{/gist_id}","starred_url":"https://api.github.com/users/AndriySvyryd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndriySvyryd/subscriptions","organizations_url":"https://api.github.com/users/AndriySvyryd/orgs","repos_url":"https://api.github.com/users/AndriySvyryd/repos","events_url":"https://api.github.com/users/AndriySvyryd/events{/privacy}","received_events_url":"https://api.github.com/users/AndriySvyryd/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T00:43:13Z","updated_at":"2016-01-13T00:43:13Z","body":"@Grinderofl, sorry I didn't explain the purpose of the model cache key. It is to be used for the model cache in ModelSource. So `ConcurrentDictionary<Type, IModel> _models` would become `ConcurrentDictionary<ModelCacheKey, IModel> _models`, the default implementation of `ModelCacheKey.Equals` would just compare the stored `DbContext` types. Note that `ModelCacheKey` shouldn't store the `DbContext` instance to avoid leaking memory. This means that `IModelCustomizer.Customize` should take a `DbContext` instead of a `ModelCacheKey`\r\n\r\nThis would allow customizing the model differently depending on the `DbContext` instance data. E.g. one could put a property for a custom schema to be used for the particular `DbContext` instance, then implement custom `IModelCustomizer` that configures the model appropriately and a custom `ModelCacheKey` that would also use the schema for equals comparison.\r\n\r\nWe don't have a consensus oh what is the best way to add custom actions, so to make the PR simpler and more likely to go in sooner we can remove the requierement to add actions without modifying the service provider. This would make the default implementation `ModelCustomizer` very simple: it would just call `OnModelCreating`, so `ModelCustomizerOptions` and `ModelCustomizerOptionsSetup` can be removed. As long as `IModelCustomizer` is in DI, the users can choose and implement whatever makes more sense for their scenario. You could move `ModelCustomizerOptions` and `ModelCustomizerOptionsSetup` to the test to ensure that it can still be used like that."}}