Table of Contents

Class InversePropertyAttributeConvention

Namespace
Microsoft.EntityFrameworkCore.Metadata.Conventions
Assembly
Microsoft.EntityFrameworkCore.dll

A convention that configures the inverse navigation property based on the InversePropertyAttribute specified on the other navigation property.

public class InversePropertyAttributeConvention : NavigationAttributeConventionBase<InversePropertyAttribute>, IEntityTypeAddedConvention, IEntityTypeRemovedConvention, IEntityTypeBaseTypeChangedConvention, IEntityTypeMemberIgnoredConvention, INavigationAddedConvention, IModelFinalizingConvention, IConvention
Inheritance
InversePropertyAttributeConvention
Implements
Inherited Members

Remarks

See Model building conventions for more information and examples.

Constructors

InversePropertyAttributeConvention(ProviderConventionSetBuilderDependencies)

Creates a new instance of InversePropertyAttributeConvention.

public InversePropertyAttributeConvention(ProviderConventionSetBuilderDependencies dependencies)

Parameters

dependencies ProviderConventionSetBuilderDependencies

Parameter object containing dependencies for this convention.

Methods

IsAmbiguous(IConventionEntityType, MemberInfo, IConventionEntityType)

Returns a value indication whether the given navigation has ambiguous inverse navigations with InversePropertyAttribute.

public static bool IsAmbiguous(IConventionEntityType entityType, MemberInfo navigation, IConventionEntityType targetEntityType)

Parameters

entityType IConventionEntityType

The entity type.

navigation MemberInfo

The navigation.

targetEntityType IConventionEntityType

Target entity type.

Returns

bool

true if the given navigation has ambiguous inverse navigations with InversePropertyAttribute.

ProcessEntityTypeAdded(IConventionEntityTypeBuilder, MemberInfo, Type, InversePropertyAttribute, IConventionContext<IConventionEntityTypeBuilder>)

Called for every navigation property that has an attribute after an entity type is added to the model.

public override void ProcessEntityTypeAdded(IConventionEntityTypeBuilder entityTypeBuilder, MemberInfo navigationMemberInfo, Type targetClrType, InversePropertyAttribute attribute, IConventionContext<IConventionEntityTypeBuilder> context)

Parameters

entityTypeBuilder IConventionEntityTypeBuilder

The builder for the entity type.

navigationMemberInfo MemberInfo

The navigation member info.

targetClrType Type

The CLR type of the target entity type

attribute InversePropertyAttribute

The attribute.

context IConventionContext<IConventionEntityTypeBuilder>

Additional information associated with convention execution.

ProcessEntityTypeBaseTypeChanged(IConventionEntityTypeBuilder, IConventionEntityType?, IConventionEntityType?, IConventionContext<IConventionEntityType>)

public override void ProcessEntityTypeBaseTypeChanged(IConventionEntityTypeBuilder entityTypeBuilder, IConventionEntityType? newBaseType, IConventionEntityType? oldBaseType, IConventionContext<IConventionEntityType> context)

Parameters

entityTypeBuilder IConventionEntityTypeBuilder
newBaseType IConventionEntityType
oldBaseType IConventionEntityType
context IConventionContext<IConventionEntityType>

ProcessEntityTypeBaseTypeChanged(IConventionEntityTypeBuilder, IConventionEntityType?, IConventionEntityType?, MemberInfo, Type, InversePropertyAttribute, IConventionContext<IConventionEntityType>)

public override void ProcessEntityTypeBaseTypeChanged(IConventionEntityTypeBuilder entityTypeBuilder, IConventionEntityType? newBaseType, IConventionEntityType? oldBaseType, MemberInfo navigationMemberInfo, Type targetClrType, InversePropertyAttribute attribute, IConventionContext<IConventionEntityType> context)

Parameters

entityTypeBuilder IConventionEntityTypeBuilder
newBaseType IConventionEntityType
oldBaseType IConventionEntityType
navigationMemberInfo MemberInfo
targetClrType Type
attribute InversePropertyAttribute
context IConventionContext<IConventionEntityType>

ProcessEntityTypeMemberIgnored(IConventionEntityTypeBuilder, MemberInfo, Type, InversePropertyAttribute, IConventionContext<string>)

public override void ProcessEntityTypeMemberIgnored(IConventionEntityTypeBuilder entityTypeBuilder, MemberInfo navigationMemberInfo, Type targetClrType, InversePropertyAttribute attribute, IConventionContext<string> context)

Parameters

entityTypeBuilder IConventionEntityTypeBuilder
navigationMemberInfo MemberInfo
targetClrType Type
attribute InversePropertyAttribute
context IConventionContext<string>

ProcessEntityTypeMemberIgnored(IConventionEntityTypeBuilder, string, IConventionContext<string>)

public override void ProcessEntityTypeMemberIgnored(IConventionEntityTypeBuilder entityTypeBuilder, string name, IConventionContext<string> context)

Parameters

entityTypeBuilder IConventionEntityTypeBuilder
name string
context IConventionContext<string>

ProcessEntityTypeRemoved(IConventionModelBuilder, IConventionEntityType, MemberInfo, Type, InversePropertyAttribute, IConventionContext<IConventionEntityType>)

public override void ProcessEntityTypeRemoved(IConventionModelBuilder modelBuilder, IConventionEntityType entityType, MemberInfo navigationMemberInfo, Type targetClrType, InversePropertyAttribute attribute, IConventionContext<IConventionEntityType> context)

Parameters

modelBuilder IConventionModelBuilder
entityType IConventionEntityType
navigationMemberInfo MemberInfo
targetClrType Type
attribute InversePropertyAttribute
context IConventionContext<IConventionEntityType>

ProcessModelFinalizing(IConventionModelBuilder, IConventionContext<IConventionModelBuilder>)

public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext<IConventionModelBuilder> context)

Parameters

modelBuilder IConventionModelBuilder
context IConventionContext<IConventionModelBuilder>

ProcessNavigationAdded(IConventionNavigationBuilder, InversePropertyAttribute, IConventionContext<IConventionNavigationBuilder>)

public override void ProcessNavigationAdded(IConventionNavigationBuilder navigationBuilder, InversePropertyAttribute attribute, IConventionContext<IConventionNavigationBuilder> context)

Parameters

navigationBuilder IConventionNavigationBuilder
attribute InversePropertyAttribute
context IConventionContext<IConventionNavigationBuilder>

TryGetTargetEntityTypeBuilder(IConventionEntityTypeBuilder, Type, MemberInfo, bool)

Finds or tries to create an entity type target for the given navigation member.

protected virtual IConventionEntityTypeBuilder? TryGetTargetEntityTypeBuilder(IConventionEntityTypeBuilder entityTypeBuilder, Type targetClrType, MemberInfo navigationMemberInfo, bool shouldCreate = true)

Parameters

entityTypeBuilder IConventionEntityTypeBuilder

The builder for the referencing entity type.

targetClrType Type

The CLR type of the target entity type.

navigationMemberInfo MemberInfo

The navigation member.

shouldCreate bool

Whether an entity type should be created if one doesn't currently exist.

Returns

IConventionEntityTypeBuilder

The builder for the target entity type or null if it can't be created.