Table of Contents

Class RelationalDatabase

Namespace
Microsoft.EntityFrameworkCore.Storage
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

The main interaction point between a context and the database provider.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

The service lifetime is Scoped. This means that each Microsoft.EntityFrameworkCore.DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.

public class RelationalDatabase : Database
Inheritance
RelationalDatabase

Constructors

RelationalDatabase(DatabaseDependencies, RelationalDatabaseDependencies)

Initializes a new instance of the RelationalDatabase class.

public RelationalDatabase(DatabaseDependencies dependencies, RelationalDatabaseDependencies relationalDependencies)

Parameters

dependencies DatabaseDependencies

Parameter object containing dependencies for the base of this service.

relationalDependencies RelationalDatabaseDependencies

Parameter object containing relational dependencies for this service.

Properties

RelationalDependencies

Parameter object containing relational dependencies for this service.

protected virtual RelationalDatabaseDependencies RelationalDependencies { get; }

Property Value

RelationalDatabaseDependencies

Methods

SaveChanges(IList<IUpdateEntry>)

Persists changes from the supplied entries to the database.

public override int SaveChanges(IList<IUpdateEntry> entries)

Parameters

entries IList<IUpdateEntry>

Entries representing the changes to be persisted.

Returns

int

The number of state entries persisted to the database.

SaveChangesAsync(IList<IUpdateEntry>, CancellationToken)

Asynchronously persists changes from the supplied entries to the database.

public override Task<int> SaveChangesAsync(IList<IUpdateEntry> entries, CancellationToken cancellationToken = default)

Parameters

entries IList<IUpdateEntry>

Entries representing the changes to be persisted.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<int>

A task that represents the asynchronous save operation. The task result contains the number of entries persisted to the database.