Class ModelCacheKey
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
A key 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 ModelCacheKey
- Inheritance
-
ModelCacheKey
- Inherited Members
Remarks
See EF Core model caching for more information and examples.
Constructors
ModelCacheKey(DbContext)
Initializes a new instance of the ModelCacheKey class.
public ModelCacheKey(DbContext context)
Parameters
context
DbContextThe context instance that this key is for.
ModelCacheKey(DbContext, bool)
Initializes a new instance of the ModelCacheKey class.
public ModelCacheKey(DbContext context, bool designTime)
Parameters
context
DbContextThe context instance that this key is for.
designTime
boolWhether the model should contain design-time configuration.
Methods
Equals(ModelCacheKey)
Determines if this key is equivalent to a given key (i.e. if they are for the same context type).
protected virtual bool Equals(ModelCacheKey other)
Parameters
other
ModelCacheKeyThe key to compare this key to.
Returns
Equals(object?)
Determines if this key is equivalent to a given object (i.e. if they are keys for the same context type).
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare this key to.
Returns
- bool
true if the object is a ModelCacheKey and is for the same context type, otherwise false.
GetHashCode()
Gets the hash code for the key.
public override int GetHashCode()
Returns
- int
The hash code for the key.