RelationshipManager.InitializeRelatedReference<TTargetEntity> Method (String, String, EntityReference<TTargetEntity>)

 

Takes an existing EntityReference that was created with the default constructor and initializes it using the provided relationship and target role names. This method is designed to be used during deserialization only, and will throw an exception if the provided EntityReference has already been initialized, if the relationship manager already contains a relationship with this name and target role, or if the relationship manager is already attached to a ObjectContext.W

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

[EditorBrowsableAttribute(EditorBrowsableState.Never)]
[BrowsableAttribute(false)]
public void InitializeRelatedReference<TTargetEntity>(
	string relationshipName,
	string targetRoleName,
	EntityReference<TTargetEntity> entityReference
)
where TTargetEntity : class

Parameters

relationshipName
Type: System.String

The relationship name.

targetRoleName
Type: System.String

The role name of the related end.

entityReference
Type: System.Data.Entity.Core.Objects.DataClasses.EntityReference<TTargetEntity>

The EntityReference<TEntity> to initialize.

Type Parameters

TTargetEntity

The type of the EntityReference<TEntity> being initialized.

Exception Condition
InvalidOperationException

When the provided EntityReference<TEntity> is already initialized.-or-When the relationship manager is already attached to an ObjectContext or when the relationship manager already contains a relationship with this name and target role.