public void TestA() { using (var scope = _contextScopeFactory.CreateContextScope()) { var testDbContext = scope.GetContext <TestDbContext>(); var entityA = new EntityA { ValueA = $"some value A {DateTime.Now:s}" }; testDbContext.Set <EntityA>().Add(entityA); testDbContext.SaveChanges(); _entityBService.TestB(); scope.Save(); } }
public void TestB() { using (var scope = _contextScopeFactory.CreateContextScope()) { var testDbContext = scope.GetContext <TestDbContext>(); // var entitiesA = testDbContext.Set<EntityA>().ToList(); var entityB = new EntityB { ValueB = $"some value B {DateTime.Now:s}" }; testDbContext.Set <EntityB>().Add(entityB); testDbContext.SaveChanges(); scope.Save(); } }