> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# EntityFrameworkApi

> Represents an API over a DbContext.

## Definition

**Assembly:** Microsoft.Restier.EntityFramework.dll

**Namespace:** Microsoft.Restier.EntityFramework

**Inheritance:** Microsoft.Restier.Core.ApiBase

## Syntax

```csharp theme={"dark"}
Microsoft.Restier.EntityFramework.EntityFrameworkApi<T>
```

## Summary

Represents an API over a DbContext.

## Remarks

This class tries to instantiate *T* with the best matched constructor
base on services configured. Descendants could override by registering *T*
as a scoped service. But in this case, proxy creation must be disabled in the constructors of
*T* under Entity Framework 6.

## Type Parameters

* `T` - The DbContext type.

## Constructors

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .ctor

Initializes a new instance of the [EntityFrameworkApi\`1](https://learn.microsoft.com/dotnet/api/microsoft.restier.entityframework.entityframeworkapi-1) class.

#### Syntax

```csharp theme={"dark"}
public EntityFrameworkApi(System.IServiceProvider serviceProvider)
```

#### Parameters

| Name              | Type                      | Description                                                                                                                                                                                                                                   |
| ----------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `serviceProvider` | `System.IServiceProvider` | An [IServiceProvider](https://learn.microsoft.com/dotnet/api/system.iserviceprovider) containing all services of this [EntityFrameworkApi\`1](https://learn.microsoft.com/dotnet/api/microsoft.restier.entityframework.entityframeworkapi-1). |

## Properties

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ContextType

Gets the Context Type.

#### Syntax

```csharp theme={"dark"}
public System.Type ContextType { get; }
```

#### Property Value

Type: `System.Type`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> DbContext

Gets the underlying DbContext for this API.

#### Syntax

```csharp theme={"dark"}
public T DbContext { get; }
```

#### Property Value

Type: `T`

## Related APIs

* Microsoft.Restier.EntityFramework.IEntityFrameworkApi
