Table of Contents

Class EfCoreDbContext

Namespace
Savvyio.Extensions.EFCore
Assembly
Savvyio.Extensions.EFCore.dll

Provides a default implementation of the DbContext class to support Savvy I/O extensions of Microsoft Entity Framework Core.

public class EfCoreDbContext : DbContext, IInfrastructure<IServiceProvider>, IDbContextDependencies, IDbSetCache, IDbContextPoolable, IResettableService, IDisposable, IAsyncDisposable, IConfigurable<EfCoreDataSourceOptions>
Inheritance
EfCoreDbContext
Implements
Derived
Inherited Members

Constructors

EfCoreDbContext(EfCoreDataSourceOptions)

Initializes a new instance of the EfCoreDbContext class.

public EfCoreDbContext(EfCoreDataSourceOptions options)

Parameters

options EfCoreDataSourceOptions

The EfCoreDataSourceOptions used to configure this instance.

Properties

Options

Gets the configured options of this instance.

public EfCoreDataSourceOptions Options { get; }

Property Value

EfCoreDataSourceOptions

The configured options of this instance.

Methods

ConfigureConventions(ModelConfigurationBuilder)

Override this method to set defaults and configure conventions before they run. This method is invoked before OnModelCreating(ModelBuilder).

protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)

Parameters

configurationBuilder ModelConfigurationBuilder

The builder being used to set defaults and configure conventions that will be used to build the model for this context.

Remarks

If a model is explicitly set on the options for this context (via UseModel(IModel)) then this method will not be run.

OnConfiguring(DbContextOptionsBuilder)

Override this method to configure the database (and other options) to be used for this context. This method is called for each instance of the context that is created. The base implementation does nothing.

In situations where an instance of DbContextOptions may or may not have been passed to the constructor, you can use IsConfigured to determine if the options have already been set, and skip some or all of the logic in OnConfiguring(DbContextOptionsBuilder).

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

Parameters

optionsBuilder DbContextOptionsBuilder

A builder used to create or modify options for this context. Databases (and other extensions) typically define extension methods on this object that allow you to configure the context.

Remarks

OnModelCreating(ModelBuilder)

Override this method to further configure the model that was discovered by convention from the entity types exposed in DbSet<TEntity> properties on your derived context. The resulting model may be cached and re-used for subsequent instances of your derived context.

protected override void OnModelCreating(ModelBuilder modelBuilder)

Parameters

modelBuilder ModelBuilder

The builder being used to construct the model for this context. Databases (and other extensions) typically define extension methods on this object that allow you to configure aspects of the model that are specific to a given database.

Remarks

If a model is explicitly set on the options for this context (via UseModel(IModel)) then this method will not be run.

See Modeling entity types and relationships for more information.

See Also