Table of Contents

Class ReferenceEntry

Namespace
Microsoft.EntityFrameworkCore.ChangeTracking
Assembly
Microsoft.EntityFrameworkCore.dll

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

public class ReferenceEntry : NavigationEntry, IInfrastructure<InternalEntityEntry>
Inheritance
ReferenceEntry
Implements
Derived
Inherited Members
Extension Methods

Remarks

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.

See Accessing tracked entities in EF Core and Loading related entities for more information and examples.

Constructors

ReferenceEntry(InternalEntityEntry, INavigation)

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.

[EntityFrameworkInternal]
public ReferenceEntry(InternalEntityEntry internalEntry, INavigation navigation)

Parameters

internalEntry InternalEntityEntry
navigation INavigation

ReferenceEntry(InternalEntityEntry, string)

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.

[EntityFrameworkInternal]
public ReferenceEntry(InternalEntityEntry internalEntry, string name)

Parameters

internalEntry InternalEntityEntry
name string

Properties

IsModified

Gets or sets a value indicating whether any of foreign key property values associated with this navigation property have been modified and should be updated in the database when SaveChanges() is called.

public override bool IsModified { get; set; }

Property Value

bool

Remarks

TargetEntry

The EntityEntry of the entity this navigation targets.

public virtual EntityEntry? TargetEntry { get; }

Property Value

EntityEntry

An entry for the entity that this navigation targets.

Remarks

See Accessing tracked entities in EF Core for more information and examples.

Methods

GetTargetEntry()

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.

[EntityFrameworkInternal]
protected virtual InternalEntityEntry? GetTargetEntry()

Returns

InternalEntityEntry

Load()

Loads the entities referenced by this navigation property, unless IsLoaded is already set to true.

public override void Load()

Remarks

See Accessing tracked entities in EF Core and Loading related entities for more information and examples.

Load(LoadOptions)

Loads the entities referenced by this navigation property, unless IsLoaded is already set to true.

public override void Load(LoadOptions options)

Parameters

options LoadOptions

Options to control the way related entities are loaded.

Remarks

See Accessing tracked entities in EF Core and Loading related entities for more information and examples.

LoadAsync(LoadOptions, CancellationToken)

Loads entities referenced by this navigation property, unless IsLoaded is already set to true.

public override Task LoadAsync(LoadOptions options, CancellationToken cancellationToken = default)

Parameters

options LoadOptions

Options to control the way related entities are loaded.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task

A task that represents the asynchronous save operation.

Remarks

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.

See Accessing tracked entities in EF Core and Loading related entities for more information and examples.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

LoadAsync(CancellationToken)

Loads entities referenced by this navigation property, unless IsLoaded is already set to true.

public override Task LoadAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task

A task that represents the asynchronous save operation.

Remarks

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.

See Accessing tracked entities in EF Core and Loading related entities for more information and examples.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

Query()

Returns the query that would be used by Load() to load entities referenced by this navigation property.

public override IQueryable Query()

Returns

IQueryable

The query to load related entities.

Remarks

The query can be composed over using LINQ to perform filtering, counting, etc. without actually loading all entities from the database.

See Accessing tracked entities in EF Core and Loading related entities for more information and examples.