{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework6/issues/456","repository_url":"https://api.github.com/repos/aspnet/EntityFramework6","labels_url":"https://api.github.com/repos/aspnet/EntityFramework6/issues/456/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework6/issues/456/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework6/issues/456/events","html_url":"https://github.com/aspnet/EntityFramework6/issues/456","id":293548136,"number":456,"title":"InsertOrUpdate functionality","user":{"login":"bdebaere","id":1436449,"avatar_url":"https://avatars3.githubusercontent.com/u/1436449?v=4","gravatar_id":"","url":"https://api.github.com/users/bdebaere","html_url":"https://github.com/bdebaere","followers_url":"https://api.github.com/users/bdebaere/followers","following_url":"https://api.github.com/users/bdebaere/following{/other_user}","gists_url":"https://api.github.com/users/bdebaere/gists{/gist_id}","starred_url":"https://api.github.com/users/bdebaere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdebaere/subscriptions","organizations_url":"https://api.github.com/users/bdebaere/orgs","repos_url":"https://api.github.com/users/bdebaere/repos","events_url":"https://api.github.com/users/bdebaere/events{/privacy}","received_events_url":"https://api.github.com/users/bdebaere/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-01T14:22:52Z","updated_at":"2018-02-01T21:33:05Z","closed_at":null,"author_association":"NONE","body":"Would there be any drawback against using the code below for InsertOrUpdate functionality?\r\n\r\n```csharp\r\n        public virtual void InsertOrUpdate(Entity entity)\r\n        {\r\n            DbEntityEntry dbEntityEntry = _dbContext.Entry(entity);\r\n\r\n            if (dbEntityEntry.State == EntityState.Detached)\r\n            {\r\n                _dbSet.Add(entity);\r\n            }\r\n            else\r\n            {\r\n                _dbSet.Attach(entity);\r\n            }\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework6/issues/comments/362408877","html_url":"https://github.com/aspnet/EntityFramework6/issues/456#issuecomment-362408877","issue_url":"https://api.github.com/repos/aspnet/EntityFramework6/issues/456","id":362408877,"user":{"login":"ajcvickers","id":1430078,"avatar_url":"https://avatars1.githubusercontent.com/u/1430078?v=4","gravatar_id":"","url":"https://api.github.com/users/ajcvickers","html_url":"https://github.com/ajcvickers","followers_url":"https://api.github.com/users/ajcvickers/followers","following_url":"https://api.github.com/users/ajcvickers/following{/other_user}","gists_url":"https://api.github.com/users/ajcvickers/gists{/gist_id}","starred_url":"https://api.github.com/users/ajcvickers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajcvickers/subscriptions","organizations_url":"https://api.github.com/users/ajcvickers/orgs","repos_url":"https://api.github.com/users/ajcvickers/repos","events_url":"https://api.github.com/users/ajcvickers/events{/privacy}","received_events_url":"https://api.github.com/users/ajcvickers/received_events","type":"User","site_admin":false},"created_at":"2018-02-01T21:33:05Z","updated_at":"2018-02-01T21:33:05Z","author_association":"MEMBER","body":"@bdebaere If the entity is in the Detached state, then calling Add will mark it as Added, and calling Attach will mark is as Unchanged. On its own this does not, to me, mean InsertOrUpdate. Changing Attach to Update makes more sense since the states will then be Added or Modified. However, if the state is not Detached, then it is already being tracked by the context, which likely means that both Attach and Update are not useful."}}
{"actor":{"display_login":"ajcvickers"}}