ObjectContext.LoadProperty Method (Object, String, MergeOption)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Explicitly loads an object that is related to the supplied object by the specified navigation property and using the specified merge option.

Namespace:   System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

Public Sub LoadProperty (
	entity As Object,
	navigationProperty As String,
	mergeOption As MergeOption


Type: System.Object

The entity for which related objects are to be loaded.

Type: System.String

The name of the navigation property that returns the related objects to be loaded.

Type: System.Data.Objects.MergeOption

The MergeOption value to use when you load the related objects.

Exception Condition

The entity is in a Detached, F:System.Data.EntityState.Added, or Deleted state,


The entity is attached to another instance of ObjectContext.

The LoadProperty method must be called to achieve explicit loading when you are using POCO custom data classes.

After calling LoadProperty, the related object can be accessed through the navigation properties of the source entity.

When using POCO custom data classes, related objects cannot be explicitly loaded like instances of entity types that are generated by the Entity Data Model tools. This is because the tools generate the navigation properties that return an EntityCollection(Of TEntity) or EntityReference(Of TEntity) of related objects when Load is called on a T:System.Data.Objects.DataClasses.RelatedEnd`1. POCO entities can still be loaded by using lazy loading by setting the LazyLoadingEnabled property to true on the instance of ObjectContextOptions that is returned by the ObjectContext.ContextOptions property, or by using eager loading with the Include method on the ObjectQuery(Of T).

.NET Framework
Available since 4.0
Return to top