EntityEntry<TEntity> Class

Definition

Provides access to change tracking information and operations for a given entity.

Instances of this class are returned from methods when using the ChangeTracker API and it is not designed to be directly constructed in your application code.

public class EntityEntry<TEntity> : Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry where TEntity : class
type EntityEntry<'Entity (requires 'Entity : null)> = class
    inherit EntityEntry
Public Class EntityEntry(Of TEntity)
Inherits EntityEntry

Type Parameters

TEntity

The type of entity being tracked by this entry.

Inheritance
EntityEntry<TEntity>

Constructors

EntityEntry<TEntity>(InternalEntityEntry)

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.

Properties

Collections

Provides access to change tracking information and loading information for all collection navigation properties of this entity.

(Inherited from EntityEntry)
Context

Gets the context that is tracking the entity.

(Inherited from EntityEntry)
CurrentValues

Gets the current property values for this entity.

(Inherited from EntityEntry)
DebugView

Expand this property in the debugger for a human-readable view of entry.

Warning: Do not rely on the format of the debug strings. They are designed for debugging only and may change arbitrarily between releases.

(Inherited from EntityEntry)
Entity

Gets the entity being tracked by this entry.

InternalEntry

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.

(Inherited from EntityEntry)
IsKeySet

Gets a value indicating if the key values of this entity have been assigned a value.

For keys with store-generated properties (e.g. mapping to Identity columns), the return value will be false if any of the store-generated properties have the CLR default value.

For keys without any store-generated properties, the return value will always be true since any value is considered a valid key value.

(Inherited from EntityEntry)
Members

Provides access to change tracking information and operations for all properties and navigation properties of this entity.

(Inherited from EntityEntry)
Metadata

Gets the metadata about the shape of the entity, its relationships to other entities, and how it maps to the database.

(Inherited from EntityEntry)
Navigations

Provides access to change tracking information and operations for all navigation properties of this entity.

(Inherited from EntityEntry)
OriginalValues

Gets the original property values for this entity. The original values are the property values as they were when the entity was retrieved from the database.

Note that whenever real original property values are not available (e.g. entity was not yet persisted to the database) this will default to the current property values of this entity.

(Inherited from EntityEntry)
Properties

Provides access to change tracking information and operations for all properties of this entity.

(Inherited from EntityEntry)
References

Provides access to change tracking information and loading information for all reference (i.e. non-collection) navigation properties of this entity.

(Inherited from EntityEntry)
State

Gets or sets that state that this entity is being tracked in.

This method sets only the state of the single entity represented by this entry. It does not change the state of other entities reachable from this one.

When setting the state, the entity will always end up in the specified state. For example, if you change the state to Deleted the entity will be marked for deletion regardless of its current state. This is different than calling Remove(TEntity) where the entity will be disconnected (rather than marked for deletion) if it is in the Added state.

(Inherited from EntityEntry)

Methods

Collection(String)

Provides access to change tracking and loading information for a collection navigation property that associates this entity to a collection of another entities.

(Inherited from EntityEntry)
Collection<TProperty>(Expression<Func<TEntity,IEnumerable<TProperty>>>)

Provides access to change tracking and loading information for a collection navigation property that associates this entity to a collection of another entities.

Collection<TProperty>(String)

Provides access to change tracking and loading information for a collection navigation property that associates this entity to a collection of another entities.

DetectChanges()

Scans this entity instance to detect any changes made to the instance data. DetectChanges() is usually called automatically by the context to get up-to-date information on an individual entity before returning change tracking information. You typically only need to call this method if you have disabled AutoDetectChangesEnabled.

(Inherited from EntityEntry)
Equals(Object)

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

(Inherited from EntityEntry)
GetDatabaseValues()

Queries the database for copies of the values of the tracked entity as they currently exist in the database. If the entity is not found in the database, then null is returned.

Note that changing the values in the returned dictionary will not update the values in the database.

(Inherited from EntityEntry)
GetDatabaseValuesAsync(CancellationToken)

Queries the database for copies of the values of the tracked entity as they currently exist in the database. If the entity is not found in the database, then null is returned.

Note that changing the values in the returned dictionary will not update the values in the database.

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.

(Inherited from EntityEntry)
GetHashCode()

Serves as the default hash function.

(Inherited from EntityEntry)
Member(String)

Provides access to change tracking information and operations for a given property or navigation property of this entity.

(Inherited from EntityEntry)
Navigation(String)

Provides access to change tracking information and operations for a given navigation property of this entity.

(Inherited from EntityEntry)
Property(String)

Provides access to change tracking information and operations for a given property of this entity.

(Inherited from EntityEntry)
Property<TProperty>(Expression<Func<TEntity,TProperty>>)

Provides access to change tracking information and operations for a given property of this entity.

Property<TProperty>(String)

Provides access to change tracking information and operations for a given property of this entity.

Reference(String)

Provides access to change tracking and loading information for a reference (i.e. non-collection) navigation property that associates this entity to another entity.

(Inherited from EntityEntry)
Reference<TProperty>(Expression<Func<TEntity,TProperty>>)

Provides access to change tracking and loading information for a reference (i.e. non-collection) navigation property that associates this entity to another entity.

Reference<TProperty>(String)

Provides access to change tracking and loading information for a reference (i.e. non-collection) navigation property that associates this entity to another entity.

Reload()

Reloads the entity from the database overwriting any property values with values from the database.

The entity will be in the Unchanged state after calling this method, unless the entity does not exist in the database, in which case the entity will be Detached. Finally, calling Reload on an Added entity that does not exist in the database is a no-op. Note, however, that an Added entity may not yet have had its permanent key value created.

(Inherited from EntityEntry)
ReloadAsync(CancellationToken)

Reloads the entity from the database overwriting any property values with values from the database.

The entity will be in the Unchanged state after calling this method, unless the entity does not exist in the database, in which case the entity will be Detached. Finally, calling Reload on an Added entity that does not exist in the database is a no-op. Note, however, that an Added entity may not yet have had its permanent key value created.

(Inherited from EntityEntry)
ToString()

Returns a string that represents the current object.

(Inherited from EntityEntry)

Explicit Interface Implementations

IInfrastructure<InternalEntityEntry>.Instance

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.

(Inherited from EntityEntry)

Extension Methods

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.

Applies to