# DbContext

`class` `public` `abstract`

```csharp
namespace Core.Data;

public abstract class DbContext : IDisposable
```

A minimal unit of work that tracks entity changes.

## Constructors

{% member id="ctor" %}
```csharp
protected DbContext()
```

Initializes a new instance of the `object` class.

{% /member %}

## Methods

{% member id="savechangesasync" %}
```csharp
public abstract Task<int> SaveChangesAsync(
    CancellationToken cancellationToken = default
)
```

Persists all tracked changes to the store.

* **cancellationToken**: A token to observe for cancellation requests.

**Returns**: The number of state entries written to the store.

**Throws** `InvalidOperationException`: Thrown when the context was disposed.

{% /member %}

{% member id="dispose" %}
```csharp
public virtual void Dispose()
```

Releases the context.

{% /member %}
