DbContext DbContext DbContext Class

Definition

A DbContext instance represents a session with the database and can be used to query and save instances of your entities. DbContext is a combination of the Unit Of Work and Repository patterns.

public class DbContext : IAsyncDisposable, IDisposable, Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider>, Microsoft.EntityFrameworkCore.Internal.IDbContextDependencies, Microsoft.EntityFrameworkCore.Internal.IDbContextPoolable, Microsoft.EntityFrameworkCore.Internal.IDbSetCache
type DbContext = class
    interface IDisposable
    interface IAsyncDisposable
    interface IInfrastructure<IServiceProvider>
    interface IDbContextDependencies
    interface IDbSetCache
    interface IDbContextPoolable
    interface IResettableService
Public Class DbContext
Implements IAsyncDisposable, IDbContextDependencies, IDbContextPoolable, IDbSetCache, IDisposable, IInfrastructure(Of IServiceProvider)
Inheritance
DbContextDbContextDbContext
Implements
IInfrastructure<IServiceProvider> IResettableServiceIResettableServiceIResettableService Microsoft.EntityFrameworkCore.Internal.IDbContextDependenciesMicrosoft.EntityFrameworkCore.Internal.IDbContextDependenciesMicrosoft.EntityFrameworkCore.Internal.IDbContextDependencies Microsoft.EntityFrameworkCore.Internal.IDbContextPoolableMicrosoft.EntityFrameworkCore.Internal.IDbContextPoolableMicrosoft.EntityFrameworkCore.Internal.IDbContextPoolable Microsoft.EntityFrameworkCore.Internal.IDbSetCacheMicrosoft.EntityFrameworkCore.Internal.IDbSetCacheMicrosoft.EntityFrameworkCore.Internal.IDbSetCache IAsyncDisposableIAsyncDisposableIAsyncDisposable IDisposableIDisposableIDisposable

Remarks

Typically you create a class that derives from DbContext and contains DbSet<TEntity> properties for each entity in the model. If the DbSet<TEntity> properties have a public setter, they are automatically initialized when the instance of the derived context is created.

Override the OnConfiguring(DbContextOptionsBuilder) method to configure the database (and other options) to be used for the context. Alternatively, if you would rather perform configuration externally instead of inline in your context, you can use DbContextOptionsBuilder<TContext> (or DbContextOptionsBuilder) to externally create an instance of DbContextOptions<TContext> (or DbContextOptions) and pass it to a base constructor of DbContext.

The model is discovered by running a set of conventions over the entity classes found in the DbSet<TEntity> properties on the derived context. To further configure the model that is discovered by convention, you can override the OnModelCreating(ModelBuilder) method.

Constructors

DbContext() DbContext() DbContext()

Initializes a new instance of the DbContext class. The OnConfiguring(DbContextOptionsBuilder) method will be called to configure the database (and other options) to be used for this context.

DbContext(DbContextOptions) DbContext(DbContextOptions) DbContext(DbContextOptions)

Initializes a new instance of the DbContext class using the specified options. The OnConfiguring(DbContextOptionsBuilder) method will still be called to allow further configuration of the options.

Properties

ChangeTracker ChangeTracker ChangeTracker

Provides access to information and operations for entity instances this context is tracking.

ContextId ContextId ContextId

A unique identifier for the context instance and pool lease, if any.

This identifier is primarily intended as a correlation ID for logging and debugging such that it is easy to identify that multiple events are using the same or different context instances.

Database Database Database

Provides access to database related information and operations for this context.

Model Model Model

The metadata about the shape of entities, the relationships between them, and how they map to the database.

Methods

Add(Object) Add(Object) Add(Object)

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

Use State to set the state of only a single entity.

Add<TEntity>(TEntity) Add<TEntity>(TEntity) Add<TEntity>(TEntity)

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

Use State to set the state of only a single entity.

AddAsync(Object, CancellationToken) AddAsync(Object, CancellationToken) AddAsync(Object, CancellationToken)

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

Use State to set the state of only a single entity.

This method is async only to allow special value generators, such as the one used by 'Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo', to access the database asynchronously. For all other cases the non async method should be used.

AddAsync<TEntity>(TEntity, CancellationToken) AddAsync<TEntity>(TEntity, CancellationToken) AddAsync<TEntity>(TEntity, CancellationToken)

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

This method is async only to allow special value generators, such as the one used by 'Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo', to access the database asynchronously. For all other cases the non async method should be used.

AddRange(IEnumerable<Object>) AddRange(IEnumerable<Object>) AddRange(IEnumerable<Object>)

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRange(Object[]) AddRange(Object[]) AddRange(Object[])

Begins tracking the given entities, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

AddRangeAsync(Object[]) AddRangeAsync(Object[]) AddRangeAsync(Object[])

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

This method is async only to allow special value generators, such as the one used by 'Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo', to access the database asynchronously. For all other cases the non async method should be used.

AddRangeAsync(IEnumerable<Object>, CancellationToken) AddRangeAsync(IEnumerable<Object>, CancellationToken) AddRangeAsync(IEnumerable<Object>, CancellationToken)

Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called.

This method is async only to allow special value generators, such as the one used by 'Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo', to access the database asynchronously. For all other cases the non async method should be used.

Attach(Object) Attach(Object) Attach(Object)

Begins tracking the given entity and entries reachable from the given entity using the Unchanged state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure only new entities will be inserted. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Unchanged.

Use State to set the state of only a single entity.

Attach<TEntity>(TEntity) Attach<TEntity>(TEntity) Attach<TEntity>(TEntity)

Begins tracking the given entity and entries reachable from the given entity using the Unchanged state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure only new entities will be inserted. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Unchanged.

Use State to set the state of only a single entity.

AttachRange(IEnumerable<Object>) AttachRange(IEnumerable<Object>) AttachRange(IEnumerable<Object>)

Begins tracking the given entities and entries reachable from the given entities using the Unchanged state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure only new entities will be inserted. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Unchanged.

Use State to set the state of only a single entity.

AttachRange(Object[]) AttachRange(Object[]) AttachRange(Object[])

Begins tracking the given entities and entries reachable from the given entities using the Unchanged state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure only new entities will be inserted. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Unchanged.

Use State to set the state of only a single entity.

Dispose() Dispose() Dispose()

Releases the allocated resources for this context.

DisposeAsync() DisposeAsync() DisposeAsync()

Releases the allocated resources for this context.

Entry(Object) Entry(Object) Entry(Object)

Gets an EntityEntry for the given entity. The entry provides access to change tracking information and operations for the entity.

This method may be called on an entity that is not tracked. You can then set the State property on the returned entry to have the context begin tracking the entity in the specified state.

Entry<TEntity>(TEntity) Entry<TEntity>(TEntity) Entry<TEntity>(TEntity)

Gets an EntityEntry<TEntity> for the given entity. The entry provides access to change tracking information and operations for the entity.

Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

Find(Type, Object[]) Find(Type, Object[]) Find(Type, Object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

Find<TEntity>(Object[]) Find<TEntity>(Object[]) Find<TEntity>(Object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

FindAsync(Type, Object[]) FindAsync(Type, Object[]) FindAsync(Type, Object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

FindAsync(Type, Object[], CancellationToken) FindAsync(Type, Object[], CancellationToken) FindAsync(Type, Object[], CancellationToken)

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

FindAsync<TEntity>(Object[]) FindAsync<TEntity>(Object[]) FindAsync<TEntity>(Object[])

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

FindAsync<TEntity>(Object[], CancellationToken) FindAsync<TEntity>(Object[], CancellationToken) FindAsync<TEntity>(Object[], CancellationToken)

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the database for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found, then null is returned.

GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

OnConfiguring(DbContextOptionsBuilder) OnConfiguring(DbContextOptionsBuilder) 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).

OnModelCreating(ModelBuilder) OnModelCreating(ModelBuilder) 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.

Query<TQuery>() Query<TQuery>() Query<TQuery>()

Creates a DbSet<TEntity> that can be used to query instances of TQuery.

Remove(Object) Remove(Object) Remove(Object)

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

Remove<TEntity>(TEntity) Remove<TEntity>(TEntity) Remove<TEntity>(TEntity)

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

RemoveRange(Object[]) RemoveRange(Object[]) RemoveRange(Object[])

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

RemoveRange(IEnumerable<Object>) RemoveRange(IEnumerable<Object>) RemoveRange(IEnumerable<Object>)

Begins tracking the given entity in the Deleted state such that it will be removed from the database when SaveChanges() is called.

SaveChanges(Boolean) SaveChanges(Boolean) SaveChanges(Boolean)

Saves all changes made in this context to the database.

This method will automatically call DetectChanges() to discover any changes to entity instances before saving to the underlying database. This can be disabled via AutoDetectChangesEnabled.

SaveChanges() SaveChanges() SaveChanges()

Saves all changes made in this context to the database.

This method will automatically call DetectChanges() to discover any changes to entity instances before saving to the underlying database. This can be disabled via AutoDetectChangesEnabled.

SaveChangesAsync(CancellationToken) SaveChangesAsync(CancellationToken) SaveChangesAsync(CancellationToken)

Saves all changes made in this context to the database.

This method will automatically call DetectChanges() to discover any changes to entity instances before saving to the underlying database. This can be disabled via AutoDetectChangesEnabled.

Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.

SaveChangesAsync(Boolean, CancellationToken) SaveChangesAsync(Boolean, CancellationToken) SaveChangesAsync(Boolean, CancellationToken)

Saves all changes made in this context to the database.

This method will automatically call DetectChanges() to discover any changes to entity instances before saving to the underlying database. This can be disabled via AutoDetectChangesEnabled.

Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.

Set<TEntity>() Set<TEntity>() Set<TEntity>()

Creates a DbSet<TEntity> that can be used to query and save instances of TEntity.

ToString() ToString() ToString()

Returns a string that represents the current object.

Update(Object) Update(Object) Update(Object)

Begins tracking the given entity and entries reachable from the given entity using the Modified state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Modified state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure new entities will be inserted, while existing entities will be updated. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Modified.

Use State to set the state of only a single entity.

Update<TEntity>(TEntity) Update<TEntity>(TEntity) Update<TEntity>(TEntity)

Begins tracking the given entity and entries reachable from the given entity using the Modified state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Modified state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure new entities will be inserted, while existing entities will be updated. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Modified.

Use State to set the state of only a single entity.

UpdateRange(Object[]) UpdateRange(Object[]) UpdateRange(Object[])

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Modified state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure new entities will be inserted, while existing entities will be updated. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Modified.

Use State to set the state of only a single entity.

UpdateRange(IEnumerable<Object>) UpdateRange(IEnumerable<Object>) UpdateRange(IEnumerable<Object>)

Begins tracking the given entities and entries reachable from the given entities using the Modified state by default, but see below for cases when a different state will be used.

Generally, no database interaction will be performed until SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. All entities found will be tracked by the context.

For entity types with generated keys if an entity has its primary key value set then it will be tracked in the Modified state. If the primary key value is not set then it will be tracked in the Added state. This helps ensure new entities will be inserted, while existing entities will be updated. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

For entity types without generated keys, the state set is always Modified.

Use State to set the state of only a single entity.

Explicit Interface Implementations

IInfrastructure<IServiceProvider>.Instance IInfrastructure<IServiceProvider>.Instance IInfrastructure<IServiceProvider>.Instance

Gets the scoped IServiceProvider being used to resolve services.

This property is intended for use by extension methods that need to make use of services not directly exposed in the public API surface.

IResettableService.ResetState() IResettableService.ResetState() IResettableService.ResetState()

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IResettableService.ResetStateAsync(CancellationToken) IResettableService.ResetStateAsync(CancellationToken) IResettableService.ResetStateAsync(CancellationToken)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.ChangeDetector IDbContextDependencies.ChangeDetector IDbContextDependencies.ChangeDetector

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.EntityFinderFactory IDbContextDependencies.EntityFinderFactory IDbContextDependencies.EntityFinderFactory

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.EntityFinderSource IDbContextDependencies.EntityFinderSource IDbContextDependencies.EntityFinderSource

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

IDbContextDependencies.EntityGraphAttacher IDbContextDependencies.EntityGraphAttacher IDbContextDependencies.EntityGraphAttacher

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.InfrastructureLogger IDbContextDependencies.InfrastructureLogger IDbContextDependencies.InfrastructureLogger

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.QueryProvider IDbContextDependencies.QueryProvider IDbContextDependencies.QueryProvider

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.QuerySource IDbContextDependencies.QuerySource IDbContextDependencies.QuerySource

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

IDbContextDependencies.SetSource IDbContextDependencies.SetSource IDbContextDependencies.SetSource

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.StateManager IDbContextDependencies.StateManager IDbContextDependencies.StateManager

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextDependencies.UpdateLogger IDbContextDependencies.UpdateLogger IDbContextDependencies.UpdateLogger

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextPoolable.ResetState() IDbContextPoolable.ResetState() IDbContextPoolable.ResetState()
IDbContextPoolable.Resurrect(DbContextPoolConfigurationSnapshot) IDbContextPoolable.Resurrect(DbContextPoolConfigurationSnapshot) IDbContextPoolable.Resurrect(DbContextPoolConfigurationSnapshot)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextPoolable.SetPool(IDbContextPool) IDbContextPoolable.SetPool(IDbContextPool) IDbContextPoolable.SetPool(IDbContextPool)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbContextPoolable.SnapshotConfiguration() IDbContextPoolable.SnapshotConfiguration() IDbContextPoolable.SnapshotConfiguration()

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

IDbQueryCache.GetOrAddQuery(IDbQuerySource, Type) IDbQueryCache.GetOrAddQuery(IDbQuerySource, Type) IDbQueryCache.GetOrAddQuery(IDbQuerySource, Type)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

IDbSetCache.GetOrAddSet(IDbSetSource, Type) IDbSetCache.GetOrAddSet(IDbSetSource, Type) IDbSetCache.GetOrAddSet(IDbSetSource, Type)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

Extension Methods

GetInfrastructure<T>(IInfrastructure<T>) GetInfrastructure<T>(IInfrastructure<T>) GetInfrastructure<T>(IInfrastructure<T>)

Gets the value from a property that is being hidden using IInfrastructure<T>.

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

IInfrastructure<T> is used to hide properties that are not intended to be used in application code but can be used in extension methods written by database providers etc.

CreateProxy(DbContext, Type, Object[]) CreateProxy(DbContext, Type, Object[]) CreateProxy(DbContext, Type, Object[])

Creates a proxy instance for an entity type if proxy creation has been turned on.

CreateProxy<TEntity>(DbContext, Object[]) CreateProxy<TEntity>(DbContext, Object[]) CreateProxy<TEntity>(DbContext, Object[])

Creates a proxy instance for an entity type if proxy creation has been turned on.

Applies to