Table of Contents

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 DbContext

The 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 DbContext

The context instance that this key is for.

designTime bool

Whether 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 ModelCacheKey

The key to compare this key to.

Returns

bool

true if the key is for the same context type, otherwise false.

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 object

The 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.