Table of Contents

Class DesignTimeDbContextFactoryBase<TContext>

Namespace
NuvTools.Data.EntityFrameworkCore.Design
Assembly
NuvTools.Data.EntityFrameworkCore.dll

Base class for implementing design-time DbContext factories. Used by Entity Framework Core tools (like migrations) to create DbContext instances at design time.

public abstract class DesignTimeDbContextFactoryBase<TContext> : IDesignTimeDbContextFactory<TContext> where TContext : DbContext

Type Parameters

TContext

The type of DbContext to create.

Inheritance
DesignTimeDbContextFactoryBase<TContext>
Implements
Inherited Members

Properties

Configuration

Contains the configuration settings loaded from JSON files.

protected IConfiguration? Configuration { get; }

Property Value

IConfiguration
See Also

Methods

CreateDbContext(string[])

Creates a new instance of the DbContext. Called by Entity Framework Core tools.

public TContext CreateDbContext(string[] args)

Parameters

args string[]

Command-line arguments passed by the tooling.

Returns

TContext

A new instance of the DbContext.

CreateNewInstance(DbContextOptionsBuilder<TContext>)

Creates a new instance of the DbContext with the specified options builder. Override this method to configure the DbContext options (e.g., connection string, database provider).

protected abstract TContext CreateNewInstance(DbContextOptionsBuilder<TContext> optionsBuilder)

Parameters

optionsBuilder DbContextOptionsBuilder<TContext>

The options builder to configure.

Returns

TContext

A new instance of the DbContext.

InitializeConfiguration(params JsonConfigurationSource[])

Initializes the configuration settings from one or more JSON files. The base path is set to the current directory.

protected void InitializeConfiguration(params JsonConfigurationSource[] files)

Parameters

files JsonConfigurationSource[]

One or more JSON configuration sources to load settings from.