public async Task Edit() { try { // Insert seed data into the database using one instance of the context using (var context = new BloggingContext(DBFixture.Setup.DbOpts)) { var repository = new BloggingRepository(context); await repository.AddAsync(new Blog { Url = "http://some.address.com/foo" }); await repository.SaveAsync(); } // Use a clean instance of the context to run the test using (var context = new BloggingContext(DBFixture.Setup.DbOpts)) { var repository = new BloggingRepository(context); var result = (await repository.FindByAsync(x => x.Url == "http://some.address.com/foo")).FirstOrDefault(); Assert.NotNull(result); result.Url = "http://domain.com/bar"; repository.Edit(result); await repository.SaveAsync(); } using (var context = new BloggingContext(DBFixture.Setup.DbOpts)) { var repository = new BloggingRepository(context); var result = await repository.FindByAsync(x => x.Url.StartsWith("http://domain.com")); Assert.Equal("http://domain.com/bar", result.First().Url); } } catch (Exception) { throw; } }