{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3470","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3470/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3470/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3470/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3470","id":111994140,"number":3470,"title":"Review nested transaction behavior","user":{"login":"VeselovAndrey","id":13725003,"avatar_url":"https://avatars.githubusercontent.com/u/13725003?v=3","gravatar_id":"","url":"https://api.github.com/users/VeselovAndrey","html_url":"https://github.com/VeselovAndrey","followers_url":"https://api.github.com/users/VeselovAndrey/followers","following_url":"https://api.github.com/users/VeselovAndrey/following{/other_user}","gists_url":"https://api.github.com/users/VeselovAndrey/gists{/gist_id}","starred_url":"https://api.github.com/users/VeselovAndrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VeselovAndrey/subscriptions","organizations_url":"https://api.github.com/users/VeselovAndrey/orgs","repos_url":"https://api.github.com/users/VeselovAndrey/repos","events_url":"https://api.github.com/users/VeselovAndrey/events{/privacy}","received_events_url":"https://api.github.com/users/VeselovAndrey/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/pri0","name":"pri0","color":"e11d21"},{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/task","name":"task","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"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},"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/7","html_url":"https://github.com/aspnet/EntityFramework/milestones/7.0.0","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/7/labels","id":666128,"number":7,"title":"7.0.0","description":"","creator":{"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},"open_issues":174,"closed_issues":6,"state":"open","created_at":"2014-05-21T19:25:32Z","updated_at":"2015-10-20T18:48:17Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-10-18T01:26:20Z","updated_at":"2015-10-21T08:04:20Z","closed_at":null,"body":"Hi.\r\nIs nesting transactions supported?\r\n\r\nI'm trying to implement 2 following scenarios with nested transactions:\r\n1)\r\n```\r\nvar rootTransaction = context.Database.BeginTransaction();\r\n// Add 1st part of data to DB \r\nvar innerTransaction = context.Database.BeginTransaction();\r\n// Add 2nd part of data to DB \r\ninnerTransaction.Rollback();\r\nrootTransaction.Commit();\r\n```\r\nIn this case all will be ok. In DB will be stored 1st part of data only.\r\n\r\n2) \r\n```\r\nvar rootTransaction = context.Database.BeginTransaction();\r\n// Add 1st part of data to DB \r\nvar innerTransaction = context.Database.BeginTransaction();\r\n// Add 2nd part of data to DB \r\ninnerTransaction.Commit();\r\nrootTransaction.Rollback();\r\n```\r\nI assume that all data should be removed from DB as I made rollback root transaction.\r\nBut 2nd part of data still exist in DB.\r\n\r\nHow to implement nested transactions?"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/149810232","html_url":"https://github.com/aspnet/EntityFramework/issues/3470#issuecomment-149810232","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3470","id":149810232,"user":{"login":"roji","id":1862641,"avatar_url":"https://avatars.githubusercontent.com/u/1862641?v=3","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"created_at":"2015-10-21T08:04:20Z","updated_at":"2015-10-21T08:04:20Z","body":"From a PostgreSQL perspective, note that nested or autonomous transactions aren't supported (see [discussion](https://wiki.postgresql.org/wiki/Autonomous_subtransactions), although [savepoints are](http://www.postgresql.org/docs/9.4/static/sql-savepoint.html).\r\n\r\nI'm not sure what kind of cross-provider behavior you're aiming for with this, it may be acceptable to simply allow nested transactions at the API level (Begin within Begin), and providers not supporting this would bomb. This is how things work at the ADO.NET level."}}