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

[System.Diagnostics.DebuggerDisplay("{_internalEntityEntry,nq}")]
public class EntityEntry : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry>
[System.Diagnostics.DebuggerDisplay("{InternalEntry,nq}")]
public class EntityEntry : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry>
[<System.Diagnostics.DebuggerDisplay("{_internalEntityEntry,nq}")>]
type EntityEntry = class
    interface IInfrastructure<InternalEntityEntry>
[<System.Diagnostics.DebuggerDisplay("{InternalEntry,nq}")>]
type EntityEntry = class
    interface IInfrastructure<InternalEntityEntry>
Public Class EntityEntry
Implements IInfrastructure(Of InternalEntityEntry)
Inheritance
EntityEntry
Derived
Attributes
Implements
IInfrastructure<Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry>

Constructors

EntityEntry(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.

Context

Gets the context that is tracking the entity.

CurrentValues

Gets the current property values for this entity.

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.

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.

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.

Members

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

Metadata

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

Navigations

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

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.

Properties

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

References

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

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.

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.

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.

Equals(Object)

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

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.

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.

GetHashCode()

Serves as the default hash function.

Member(String)

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

Navigation(String)

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

Property(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.

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.

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.

ToString()

Returns a string that represents the current object.

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.

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