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
ProviderConventionSetBuilderDependenciesParameter 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
IConventionEntityTypeThe entity type.
navigation
MemberInfoThe navigation.
targetEntityType
IConventionEntityTypeTarget 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
IConventionEntityTypeBuilderThe builder for the entity type.
navigationMemberInfo
MemberInfoThe navigation member info.
targetClrType
TypeThe CLR type of the target entity type
attribute
InversePropertyAttributeThe 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
IConventionEntityTypeBuildernewBaseType
IConventionEntityTypeoldBaseType
IConventionEntityTypecontext
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
IConventionEntityTypeBuildernewBaseType
IConventionEntityTypeoldBaseType
IConventionEntityTypenavigationMemberInfo
MemberInfotargetClrType
Typeattribute
InversePropertyAttributecontext
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
IConventionEntityTypeBuildernavigationMemberInfo
MemberInfotargetClrType
Typeattribute
InversePropertyAttributecontext
IConventionContext<string>
ProcessEntityTypeMemberIgnored(IConventionEntityTypeBuilder, string, IConventionContext<string>)
public override void ProcessEntityTypeMemberIgnored(IConventionEntityTypeBuilder entityTypeBuilder, string name, IConventionContext<string> context)
Parameters
entityTypeBuilder
IConventionEntityTypeBuildername
stringcontext
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
IConventionModelBuilderentityType
IConventionEntityTypenavigationMemberInfo
MemberInfotargetClrType
Typeattribute
InversePropertyAttributecontext
IConventionContext<IConventionEntityType>
ProcessModelFinalizing(IConventionModelBuilder, IConventionContext<IConventionModelBuilder>)
public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext<IConventionModelBuilder> context)
Parameters
modelBuilder
IConventionModelBuildercontext
IConventionContext<IConventionModelBuilder>
ProcessNavigationAdded(IConventionNavigationBuilder, InversePropertyAttribute, IConventionContext<IConventionNavigationBuilder>)
public override void ProcessNavigationAdded(IConventionNavigationBuilder navigationBuilder, InversePropertyAttribute attribute, IConventionContext<IConventionNavigationBuilder> context)
Parameters
navigationBuilder
IConventionNavigationBuilderattribute
InversePropertyAttributecontext
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
IConventionEntityTypeBuilderThe builder for the referencing entity type.
targetClrType
TypeThe CLR type of the target entity type.
navigationMemberInfo
MemberInfoThe navigation member.
shouldCreate
boolWhether 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.