diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs index e84bb77fb4e..77f393e5c86 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs @@ -114,42 +114,6 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken return Task.CompletedTask; } - /// - public virtual void CreateSavepoint(string name) - => _logger.TransactionIgnoredWarning(); - - /// - public virtual Task CreateSavepointAsync(string name, CancellationToken cancellationToken = default) - { - _logger.TransactionIgnoredWarning(); - return Task.CompletedTask; - } - - /// - public virtual void RollbackToSavepoint(string name) - => _logger.TransactionIgnoredWarning(); - - /// - public virtual Task RollbackToSavepointAsync(string name, CancellationToken cancellationToken = default) - { - _logger.TransactionIgnoredWarning(); - return Task.CompletedTask; - } - - /// - public virtual void ReleaseSavepoint(string name) - => _logger.TransactionIgnoredWarning(); - - /// - public virtual Task ReleaseSavepointAsync(string name, CancellationToken cancellationToken = default) - { - _logger.TransactionIgnoredWarning(); - return Task.CompletedTask; - } - - /// - public virtual bool SupportsSavepoints => true; - /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in diff --git a/src/EFCore.Relational/Storage/RelationalConnection.cs b/src/EFCore.Relational/Storage/RelationalConnection.cs index 9591b42517e..725c2b2ca97 100644 --- a/src/EFCore.Relational/Storage/RelationalConnection.cs +++ b/src/EFCore.Relational/Storage/RelationalConnection.cs @@ -531,86 +531,6 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken return CurrentTransaction.RollbackAsync(cancellationToken); } - /// - public virtual void CreateSavepoint(string name) - { - if (CurrentTransaction == null) - { - throw new InvalidOperationException(RelationalStrings.NoActiveTransaction); - } - - CurrentTransaction.CreateSavepoint(name); - } - - /// - public virtual Task CreateSavepointAsync(string name, CancellationToken cancellationToken = default) - { - if (CurrentTransaction == null) - { - throw new InvalidOperationException(RelationalStrings.NoActiveTransaction); - } - - return CurrentTransaction.CreateSavepointAsync(name, cancellationToken); - } - - /// - public virtual void RollbackToSavepoint(string name) - { - if (CurrentTransaction == null) - { - throw new InvalidOperationException(RelationalStrings.NoActiveTransaction); - } - - CurrentTransaction.RollbackToSavepoint(name); - } - - /// - public virtual Task RollbackToSavepointAsync(string name, CancellationToken cancellationToken = default) - { - if (CurrentTransaction == null) - { - throw new InvalidOperationException(RelationalStrings.NoActiveTransaction); - } - - return CurrentTransaction.RollbackToSavepointAsync(name, cancellationToken); - } - - /// - public virtual void ReleaseSavepoint(string name) - { - if (CurrentTransaction == null) - { - throw new InvalidOperationException(RelationalStrings.NoActiveTransaction); - } - - CurrentTransaction.ReleaseSavepoint(name); - } - - /// - public virtual Task ReleaseSavepointAsync(string name, CancellationToken cancellationToken = default) - { - if (CurrentTransaction == null) - { - throw new InvalidOperationException(RelationalStrings.NoActiveTransaction); - } - - return CurrentTransaction.ReleaseSavepointAsync(name, cancellationToken); - } - - /// - public virtual bool SupportsSavepoints - { - get - { - if (CurrentTransaction == null) - { - throw new InvalidOperationException(RelationalStrings.NoActiveTransaction); - } - - return CurrentTransaction.SupportsSavepoints; - } - } - /// /// Opens the connection to the database. /// diff --git a/src/EFCore/Infrastructure/DatabaseFacade.cs b/src/EFCore/Infrastructure/DatabaseFacade.cs index 6f0f578c7a8..4821639a00d 100644 --- a/src/EFCore/Infrastructure/DatabaseFacade.cs +++ b/src/EFCore/Infrastructure/DatabaseFacade.cs @@ -196,73 +196,6 @@ public virtual void RollbackTransaction() public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken = default) => Dependencies.TransactionManager.RollbackTransactionAsync(cancellationToken); - /// - /// Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint - /// was established to be rolled back, restoring the transaction state to what it was at the time of the - /// savepoint. - /// - /// The name of the savepoint to be created. - public virtual void CreateSavepoint([NotNull] string name) - => Dependencies.TransactionManager.CreateSavepoint(name); - - /// - /// Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint - /// was established to be rolled back, restoring the transaction state to what it was at the time of the - /// savepoint. - /// - /// The name of the savepoint to be created. - /// The cancellation token. - /// A representing the asynchronous operation. - public virtual Task CreateSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default) - => Dependencies.TransactionManager.CreateSavepointAsync(name, cancellationToken); - - /// - /// Rolls back all commands that were executed after the specified savepoint was established. - /// - /// The name of the savepoint to roll back to. - public virtual void RollbackToSavepoint([NotNull] string name) - => Dependencies.TransactionManager.RollbackToSavepoint(name); - - /// - /// Rolls back all commands that were executed after the specified savepoint was established. - /// - /// The name of the savepoint to roll back to. - /// The cancellation token. - /// A representing the asynchronous operation. - public virtual Task RollbackToSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default) - => Dependencies.TransactionManager.RollbackToSavepointAsync(name, cancellationToken); - - /// - /// Destroys a savepoint previously defined in the current transaction. This allows the system to - /// reclaim some resources before the transaction ends. - /// - /// The name of the savepoint to release. - public virtual void ReleaseSavepoint([NotNull] string name) - => Dependencies.TransactionManager.ReleaseSavepoint(name); - - /// - /// Destroys a savepoint previously defined in the current transaction. This allows the system to - /// reclaim some resources before the transaction ends. - /// - /// The name of the savepoint to release. - /// The cancellation token. - /// A representing the asynchronous operation. - public virtual Task ReleaseSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default) - => Dependencies.TransactionManager.ReleaseSavepointAsync(name, cancellationToken); - - /// - /// Gets a value that indicates whether this instance supports - /// database savepoints. If , the methods , - /// - /// and as well as their synchronous counterparts are expected to throw - /// . - /// - /// - /// if this instance supports database savepoints; - /// otherwise, . - /// - public virtual bool SupportsSavepoints => Dependencies.TransactionManager.SupportsSavepoints; - /// /// Creates an instance of the configured . /// diff --git a/src/EFCore/Storage/IDbContextTransactionManager.cs b/src/EFCore/Storage/IDbContextTransactionManager.cs index 1cdcec93b0c..5a7050dd5c1 100644 --- a/src/EFCore/Storage/IDbContextTransactionManager.cs +++ b/src/EFCore/Storage/IDbContextTransactionManager.cs @@ -70,70 +70,6 @@ public interface IDbContextTransactionManager : IResettableService /// Task RollbackTransactionAsync(CancellationToken cancellationToken = default); - /// - /// Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint - /// was established to be rolled back, restoring the transaction state to what it was at the time of the - /// savepoint. - /// - /// The name of the savepoint to be created. - void CreateSavepoint([NotNull] string name) => throw new NotSupportedException(); - - /// - /// Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint - /// was established to be rolled back, restoring the transaction state to what it was at the time of the - /// savepoint. - /// - /// The name of the savepoint to be created. - /// The cancellation token. - /// A representing the asynchronous operation. - Task CreateSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default) - => throw new NotSupportedException(); - - /// - /// Rolls back all commands that were executed after the specified savepoint was established. - /// - /// The name of the savepoint to roll back to. - void RollbackToSavepoint([NotNull] string name) => throw new NotSupportedException(); - - /// - /// Rolls back all commands that were executed after the specified savepoint was established. - /// - /// The name of the savepoint to roll back to. - /// The cancellation token. - /// A representing the asynchronous operation. - Task RollbackToSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default) - => throw new NotSupportedException(); - - /// - /// Destroys a savepoint previously defined in the current transaction. This allows the system to - /// reclaim some resources before the transaction ends. - /// - /// The name of the savepoint to release. - void ReleaseSavepoint([NotNull] string name) => throw new NotSupportedException(); - - /// - /// Destroys a savepoint previously defined in the current transaction. This allows the system to - /// reclaim some resources before the transaction ends. - /// - /// The name of the savepoint to release. - /// The cancellation token. - /// A representing the asynchronous operation. - Task ReleaseSavepointAsync([NotNull] string name, CancellationToken cancellationToken = default) - => throw new NotSupportedException(); - - /// - /// Gets a value that indicates whether this instance supports - /// database savepoints. If , the methods , - /// - /// and as well as their synchronous counterparts are expected to throw - /// . - /// - /// - /// if this instance supports database savepoints; - /// otherwise, . - /// - bool SupportsSavepoints => false; - /// /// Gets the current transaction. /// diff --git a/test/EFCore.Tests/DatabaseFacadeTest.cs b/test/EFCore.Tests/DatabaseFacadeTest.cs index 57ebf0e6c48..1eed7e653f4 100644 --- a/test/EFCore.Tests/DatabaseFacadeTest.cs +++ b/test/EFCore.Tests/DatabaseFacadeTest.cs @@ -282,97 +282,6 @@ public async Task Can_roll_back_transaction_async() Assert.Equal(1, manager.RollbackCalls); } - [ConditionalFact] - public void Can_create_savepoint() - { - var manager = new FakeDbContextTransactionManager(new FakeDbContextTransaction()); - - var context = InMemoryTestHelpers.Instance.CreateContext( - new ServiceCollection().AddSingleton(manager)); - - context.Database.CreateSavepoint("foo"); - - Assert.Equal(1, manager.CreateSavepointCalls); - } - - [ConditionalFact] - public async Task Can_create_savepoint_async() - { - var manager = new FakeDbContextTransactionManager(new FakeDbContextTransaction()); - - var context = InMemoryTestHelpers.Instance.CreateContext( - new ServiceCollection().AddSingleton(manager)); - - await context.Database.CreateSavepointAsync("foo"); - - Assert.Equal(1, manager.CreateSavepointCalls); - } - - [ConditionalFact] - public void Can_rollback_savepoint() - { - var manager = new FakeDbContextTransactionManager(new FakeDbContextTransaction()); - - var context = InMemoryTestHelpers.Instance.CreateContext( - new ServiceCollection().AddSingleton(manager)); - - context.Database.RollbackToSavepoint("foo"); - - Assert.Equal(1, manager.RollbackSavepointCalls); - } - - [ConditionalFact] - public async Task Can_rollback_savepoint_async() - { - var manager = new FakeDbContextTransactionManager(new FakeDbContextTransaction()); - - var context = InMemoryTestHelpers.Instance.CreateContext( - new ServiceCollection().AddSingleton(manager)); - - await context.Database.RollbackToSavepointAsync("foo"); - - Assert.Equal(1, manager.RollbackSavepointCalls); - } - - [ConditionalFact] - public void Can_release_savepoint() - { - var manager = new FakeDbContextTransactionManager(new FakeDbContextTransaction()); - - var context = InMemoryTestHelpers.Instance.CreateContext( - new ServiceCollection().AddSingleton(manager)); - - context.Database.ReleaseSavepoint("foo"); - - Assert.Equal(1, manager.ReleaseSavepointCalls); - } - - [ConditionalFact] - public async Task Can_release_savepoint_async() - { - var manager = new FakeDbContextTransactionManager(new FakeDbContextTransaction()); - - var context = InMemoryTestHelpers.Instance.CreateContext( - new ServiceCollection().AddSingleton(manager)); - - await context.Database.ReleaseSavepointAsync("foo"); - - Assert.Equal(1, manager.ReleaseSavepointCalls); - } - - [ConditionalFact] - public void Can_check_if_checkpoints_are_supported() - { - var manager = new FakeDbContextTransactionManager(new FakeDbContextTransaction()); - - var context = InMemoryTestHelpers.Instance.CreateContext( - new ServiceCollection().AddSingleton(manager)); - - _ = context.Database.SupportsSavepoints; - - Assert.Equal(1, manager.SupportsSavepointsCalls); - } - [ConditionalFact] public void Can_get_current_transaction() {