{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3786","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3786/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3786/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3786/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3786","id":117687853,"number":3786,"title":"Inheritance update excludes \"Discriminator\"","user":{"login":"mholec","id":387784,"avatar_url":"https://avatars.githubusercontent.com/u/387784?v=3","gravatar_id":"","url":"https://api.github.com/users/mholec","html_url":"https://github.com/mholec","followers_url":"https://api.github.com/users/mholec/followers","following_url":"https://api.github.com/users/mholec/following{/other_user}","gists_url":"https://api.github.com/users/mholec/gists{/gist_id}","starred_url":"https://api.github.com/users/mholec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mholec/subscriptions","organizations_url":"https://api.github.com/users/mholec/orgs","repos_url":"https://api.github.com/users/mholec/repos","events_url":"https://api.github.com/users/mholec/events{/privacy}","received_events_url":"https://api.github.com/users/mholec/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-18T21:39:29Z","updated_at":"2015-11-19T00:20:19Z","closed_at":null,"body":"I have base class **Book** and and two sub classes **EBook** and **PrintedBook**. I have Fluent API and I use default inheritance strategy. \r\n\r\n**Database table schema:**\r\n\r\n\t- BookId (PK, int, not null)\r\n\t- CategoryId (FK, int, not null)\r\n\t- Title (nvarchar(100), not null)\r\n\t- Added (datetime, not null)\r\n\t- Url (nvarchar(max), null)\r\n\t- Discriminator (nvarchar(128), not null)\r\n\r\nI am updating one database record\r\n\r\n\t- BookId: 42\r\n\t- CategoryId: 1\r\n\t- Title: \"Whatever\"\r\n\t- Added: \"2015-11-18 22:27:45.703\"\r\n\t- Url: NULL\r\n\t- Discriminator: \"PrintedBook\"\r\n\r\nusing the change entity state this way:\r\n\r\n    EBook book2 = new EBook {BookId = 42, Title = \"Tipy a triky pro iPhone 6\", Added = DateTime.Now, CategoryId = 1, Url = \"http://\"};\r\n    context.Entry(book2).State = EntityState.Modified;\r\n    context.SaveChanges();\r\n\r\nI expected that value for Discriminator will change, because I have type EBook.\r\n\r\n**SQL produced by EF**\r\n\r\n\tUPDATE [dbo].[Books]\r\n\tSET    [CategoryId] = 1 /* @0 */,\r\n\t       [Title] = 'Tipy a triky pro iPhone 6' /* @1 */,\r\n\t       [Added] = '2015-11-18T22:35:26' /* @2 */,\r\n\t       [Url] = 'http://' /* @3 */\r\n\tWHERE  ([BookId] = 42 /* @4 - [BookId] */)\r\n\r\n**Final state in DB**\r\n\r\n\t- BookId: 42\r\n\t- CategoryId: 1\r\n\t- Title: \"Tipy a triky pro iPhone 6\"\r\n\t- Added: \"2015-11-18 22:35:26.253\"\r\n\t- Url: \"http://\"\r\n\t- Discriminator: \"PrintedBook\"  // NOT CHANGED !!!\r\n\r\nEntity Framework version 6.0.0.0"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/157906846","html_url":"https://github.com/aspnet/EntityFramework/issues/3786#issuecomment-157906846","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3786","id":157906846,"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":"2015-11-19T00:20:19Z","updated_at":"2015-11-19T00:20:19Z","body":"Hey,\r\n\r\nEF does not support mutating between types in the inheritance hierarchy (since you can't do that in .NET code either). Because you are telling EF that `book2` is an existing `EBook` it is just using the mapping for that class when it does the update.\r\n\r\n~Rowan"}}