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
TContextThe type of DbContext to create.
- Inheritance
-
DesignTimeDbContextFactoryBase<TContext>
- Implements
-
IDesignTimeDbContextFactory<TContext>
- Inherited Members
Properties
Configuration
Contains the configuration settings loaded from JSON files.
protected IConfiguration? Configuration { get; }
Property Value
- See Also
Methods
CreateDbContext(string[])
Creates a new instance of the DbContext. Called by Entity Framework Core tools.
public TContext CreateDbContext(string[] args)
Parameters
argsstring[]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
optionsBuilderDbContextOptionsBuilder<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
filesJsonConfigurationSource[]One or more JSON configuration sources to load settings from.