Class ModelCacheKeyFactory
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
Creates keys that uniquely identifies the model for a given context. This is used to store and lookup a cached model for a given context. This default implementation uses the context type as they key, thus assuming that all contexts of a given type have the same model.
public class ModelCacheKeyFactory : IModelCacheKeyFactory
- Inheritance
-
ModelCacheKeyFactory
- Implements
- Inherited Members
Remarks
The service lifetime is Singleton. This means a single instance is used by many DbContext instances. The implementation must be thread-safe. This service cannot depend on services registered as Scoped.
See EF Core model caching for more information and examples.
Constructors
ModelCacheKeyFactory(ModelCacheKeyFactoryDependencies)
Initializes a new instance of the ModelCacheKeyFactory class.
public ModelCacheKeyFactory(ModelCacheKeyFactoryDependencies dependencies)
Parameters
dependencies
ModelCacheKeyFactoryDependenciesParameter object containing dependencies for this service.
Properties
Dependencies
Dependencies for this service.
protected virtual ModelCacheKeyFactoryDependencies Dependencies { get; }
Property Value
Methods
Create(DbContext)
Gets the model cache key for a given context.
public virtual object Create(DbContext context)
Parameters
context
DbContextThe context to get the model cache key for.
Returns
- object
The created key.
Create(DbContext, bool)
Gets the model cache key for a given context.
public virtual object Create(DbContext context, bool designTime)
Parameters
context
DbContextThe context to get the model cache key for.
designTime
boolWhether the model should contain design-time configuration.
Returns
- object
The created key.