{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13368","repository_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13368/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13368/comments","events_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13368/events","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/13368","id":361887147,"node_id":"MDU6SXNzdWUzNjE4ODcxNDc=","number":13368,"title":"InMemory DbContext does not respect CancellationToken on SaveChangesAsync","user":{"login":"MatthewLymer","id":3434865,"node_id":"MDQ6VXNlcjM0MzQ4NjU=","avatar_url":"https://avatars1.githubusercontent.com/u/3434865?v=4","gravatar_id":"","url":"https://api.github.com/users/MatthewLymer","html_url":"https://github.com/MatthewLymer","followers_url":"https://api.github.com/users/MatthewLymer/followers","following_url":"https://api.github.com/users/MatthewLymer/following{/other_user}","gists_url":"https://api.github.com/users/MatthewLymer/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewLymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewLymer/subscriptions","organizations_url":"https://api.github.com/users/MatthewLymer/orgs","repos_url":"https://api.github.com/users/MatthewLymer/repos","events_url":"https://api.github.com/users/MatthewLymer/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewLymer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-19T19:07:28Z","updated_at":"2018-09-20T03:29:06Z","closed_at":null,"author_association":"NONE","body":"When using an InMemory DbContext, the `SaveChangesAsync` does not respect the cancellation token being passed in.\r\n\r\n### Steps to reproduce\r\n1. Create a DbContext called TenantDbContext\r\n1. Create a type called `Setting`, expose a `DbSet<Settings>`\r\n1. Run the following unit test:\r\n\r\n```c#\r\n\t[Fact]\r\n\tpublic async Task ShouldPersistResultIfScrapeTimesOut()\r\n\t{\r\n\t\tvar options = new DbContextOptionsBuilder<TenantDbContext>()\r\n\t\t\t.UseInMemoryDatabase(Guid.NewGuid().ToString())\r\n\t\t\t.Options;\r\n\r\n\t\tusing (var dbContext = new TenantDbContext(options))\r\n\t\t{\r\n\t\t\tvar setting = new Setting\r\n\t\t\t{\r\n\t\t\t\tName = \"Foo\", \r\n\t\t\t\tValue = \"Bar\"\r\n\t\t\t};\r\n\t\t\t\r\n\t\t\tdbContext.Settings.Add(setting);\r\n\t\t\t\r\n\t\t\tawait Assert.ThrowsAnyAsync<OperationCanceledException>(\r\n\t\t\t\t() => dbContext.SaveChangesAsync(new CancellationToken(true)));\r\n\t\t}\r\n\r\n\t\tusing (var dbContext = new TenantDbContext(options))\r\n\t\t{\r\n\t\t\tvar settings = await dbContext.Settings.ToListAsync(\r\n\t\t\t\tCancellationToken.None);\r\n\t\t\t\r\n\t\t\tAssert.Empty(settings);\r\n\t\t}\r\n\t}\r\n```\r\n\r\n### Further technical details\r\nEF Core version\r\n* Microsoft.EntityFrameworkCore.Design v2.1.0\r\n* Microsoft.EntityFrameworkCore.InMemory v2.1.1\r\n\r\nDatabase Provider\r\n* Microsoft.EntityFrameworkCore.InMemory\r\n\r\nOperating system\r\n* Windows 10\r\n\r\nIDE\r\n* Visual Studio 2017 15.8.0\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/comments/423028476","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/13368#issuecomment-423028476","issue_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13368","id":423028476,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzAyODQ3Ng==","user":{"login":"MatthewLymer","id":3434865,"node_id":"MDQ6VXNlcjM0MzQ4NjU=","avatar_url":"https://avatars1.githubusercontent.com/u/3434865?v=4","gravatar_id":"","url":"https://api.github.com/users/MatthewLymer","html_url":"https://github.com/MatthewLymer","followers_url":"https://api.github.com/users/MatthewLymer/followers","following_url":"https://api.github.com/users/MatthewLymer/following{/other_user}","gists_url":"https://api.github.com/users/MatthewLymer/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthewLymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthewLymer/subscriptions","organizations_url":"https://api.github.com/users/MatthewLymer/orgs","repos_url":"https://api.github.com/users/MatthewLymer/repos","events_url":"https://api.github.com/users/MatthewLymer/events{/privacy}","received_events_url":"https://api.github.com/users/MatthewLymer/received_events","type":"User","site_admin":false},"created_at":"2018-09-20T03:29:06Z","updated_at":"2018-09-20T03:29:06Z","author_association":"NONE","body":"I assumed as much, however I assume the entire purpose of the InMemory database is to facilitate testing, so I think having behavior closely match other providers would be desirable."}}
{"actor":{"display_login":"MatthewLymer"}}