ForeignKeyPropertyDiscoveryConvention 類別

定義

根據關聯性名稱尋找外鍵屬性的慣例,忽略大小寫:

  • [導覽屬性名稱][principal key property name]
  • [導覽屬性名稱]Id
  • [主體機構名稱][principal key property name]
  • [主體機構名稱]Id
public class ForeignKeyPropertyDiscoveryConvention : Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypeMemberIgnoredConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypePrimaryKeyChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyPrincipalEndChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyPropertiesChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyRequirednessChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyUniquenessChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IKeyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IKeyRemovedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IModelFinalizedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.INavigationAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IPropertyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IPropertyFieldChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IPropertyNullabilityChangedConvention
public class ForeignKeyPropertyDiscoveryConvention : Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypeMemberIgnoredConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypePrimaryKeyChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyPrincipalEndChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyPropertiesChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyRequirednessChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyUniquenessChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IKeyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IKeyRemovedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IModelFinalizingConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.INavigationAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IPropertyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IPropertyFieldChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IPropertyNullabilityChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.ISkipNavigationForeignKeyChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.ISkipNavigationInverseChangedConvention
type ForeignKeyPropertyDiscoveryConvention = class
    interface IForeignKeyAddedConvention
    interface IConvention
    interface INavigationAddedConvention
    interface IPropertyAddedConvention
    interface IEntityTypeMemberIgnoredConvention
    interface IPropertyNullabilityChangedConvention
    interface IPropertyFieldChangedConvention
    interface IForeignKeyPropertiesChangedConvention
    interface IForeignKeyPrincipalEndChangedConvention
    interface IForeignKeyUniquenessChangedConvention
    interface IForeignKeyRequirednessChangedConvention
    interface IKeyAddedConvention
    interface IKeyRemovedConvention
    interface IEntityTypePrimaryKeyChangedConvention
    interface IModelFinalizedConvention
type ForeignKeyPropertyDiscoveryConvention = class
    interface IEntityTypeMemberIgnoredConvention
    interface IConvention
    interface IEntityTypePrimaryKeyChangedConvention
    interface IForeignKeyAddedConvention
    interface IForeignKeyPropertiesChangedConvention
    interface IForeignKeyPrincipalEndChangedConvention
    interface IForeignKeyUniquenessChangedConvention
    interface IForeignKeyRequirednessChangedConvention
    interface IKeyAddedConvention
    interface IKeyRemovedConvention
    interface INavigationAddedConvention
    interface ISkipNavigationForeignKeyChangedConvention
    interface ISkipNavigationInverseChangedConvention
    interface IPropertyAddedConvention
    interface IPropertyNullabilityChangedConvention
    interface IPropertyFieldChangedConvention
    interface IModelFinalizingConvention
Public Class ForeignKeyPropertyDiscoveryConvention
Implements IEntityTypeMemberIgnoredConvention, IEntityTypePrimaryKeyChangedConvention, IForeignKeyAddedConvention, IForeignKeyPrincipalEndChangedConvention, IForeignKeyPropertiesChangedConvention, IForeignKeyRequirednessChangedConvention, IForeignKeyUniquenessChangedConvention, IKeyAddedConvention, IKeyRemovedConvention, IModelFinalizedConvention, INavigationAddedConvention, IPropertyAddedConvention, IPropertyFieldChangedConvention, IPropertyNullabilityChangedConvention
Public Class ForeignKeyPropertyDiscoveryConvention
Implements IEntityTypeMemberIgnoredConvention, IEntityTypePrimaryKeyChangedConvention, IForeignKeyAddedConvention, IForeignKeyPrincipalEndChangedConvention, IForeignKeyPropertiesChangedConvention, IForeignKeyRequirednessChangedConvention, IForeignKeyUniquenessChangedConvention, IKeyAddedConvention, IKeyRemovedConvention, IModelFinalizingConvention, INavigationAddedConvention, IPropertyAddedConvention, IPropertyFieldChangedConvention, IPropertyNullabilityChangedConvention, ISkipNavigationForeignKeyChangedConvention, ISkipNavigationInverseChangedConvention
繼承
ForeignKeyPropertyDiscoveryConvention
實作

備註

如果找不到相符的屬性,則關聯性不代表擁有權、相依端不模棱兩可,而且不會衍生,如果關聯性是一對一,則會使用主鍵屬性,否則慣例會嘗試比對屬性與完全名稱做為主體索引鍵屬性,因為它們是相依 PK 的適當子集。

如果找到相符專案,但屬性類型與主體索引鍵類型不相容,則不會再搜尋相符專案。

如果關聯性使用慣例所建立的陰影屬性,則會重新建立它們,以移除用來讓名稱成為唯一的尾碼。

如需詳細資訊和範例,請參閱 模型建置慣例

建構函式

ForeignKeyPropertyDiscoveryConvention(ProviderConventionSetBuilderDependencies)

建立 ForeignKeyPropertyDiscoveryConvention 的新執行個體。

屬性

Dependencies

此服務的相依性。

方法

GetPropertyBaseName(IForeignKey)

取得字串,這個字串應該用來做為指定外鍵所建立陰影屬性的一部分。

GetPropertyBaseName(IReadOnlyForeignKey)

取得字串,這個字串應該用來做為指定外鍵所建立陰影屬性的一部分。

ProcessEntityTypeMemberIgnored(IConventionEntityTypeBuilder, String, IConventionContext<String>)

忽略實體類型成員之後呼叫。

ProcessEntityTypePrimaryKeyChanged(IConventionEntityTypeBuilder, IConventionKey, IConventionKey, IConventionContext<IConventionKey>)

變更實體類型的主鍵之後呼叫。

ProcessForeignKeyAdded(IConventionForeignKeyBuilder, IConventionContext<IConventionForeignKeyBuilder>)

在將外鍵新增至實體類型之後呼叫。

ProcessForeignKeyAdded(IConventionRelationshipBuilder, IConventionContext<IConventionRelationshipBuilder>)

在將外鍵新增至實體類型之後呼叫。

ProcessForeignKeyPrincipalEndChanged(IConventionForeignKeyBuilder, IConventionContext<IConventionForeignKeyBuilder>)

在外鍵的主體結尾變更之後呼叫。

ProcessForeignKeyPrincipalEndChanged(IConventionRelationshipBuilder, IConventionContext<IConventionRelationshipBuilder>)

在外鍵的主體結尾變更之後呼叫。

ProcessForeignKeyPropertiesChanged(IConventionForeignKeyBuilder, IReadOnlyList<IConventionProperty>, IConventionKey, IConventionContext<IReadOnlyList<IConventionProperty>>)

在外鍵屬性或主體索引鍵變更之後呼叫。

ProcessForeignKeyPropertiesChanged(IConventionRelationshipBuilder, IReadOnlyList<IConventionProperty>, IConventionKey, IConventionContext<IConventionRelationshipBuilder>)

在外鍵屬性或主體索引鍵變更之後呼叫。

ProcessForeignKeyRequirednessChanged(IConventionForeignKeyBuilder, IConventionContext<Nullable<Boolean>>)

在外鍵的必要性變更之後呼叫。

ProcessForeignKeyRequirednessChanged(IConventionRelationshipBuilder, IConventionContext<IConventionRelationshipBuilder>)

在外鍵的必要性變更之後呼叫。

ProcessForeignKeyUniquenessChanged(IConventionForeignKeyBuilder, IConventionContext<Nullable<Boolean>>)

在外鍵的唯一性變更之後呼叫。

ProcessForeignKeyUniquenessChanged(IConventionRelationshipBuilder, IConventionContext<IConventionRelationshipBuilder>)

在外鍵的唯一性變更之後呼叫。

ProcessKeyAdded(IConventionKeyBuilder, IConventionContext<IConventionKeyBuilder>)

在將索引鍵新增至實體類型之後呼叫。

ProcessKeyRemoved(IConventionEntityTypeBuilder, IConventionKey, IConventionContext<IConventionKey>)

這是支援 Entity Framework Core 基礎結構的內部 API,不受與公用 API 相同的相容性標準。 它可能會在任何版本中變更或移除,而不需任何通知。 您應該只在程式碼中直接使用它,並特別小心,並知道這麼做可能會導致應用程式在更新至新的 Entity Framework Core 版本時失敗。

ProcessModelFinalized(IConventionModelBuilder, IConventionContext<IConventionModelBuilder>)

這是支援 Entity Framework Core 基礎結構的內部 API,不受與公用 API 相同的相容性標準。 它可能會在任何版本中變更或移除,而不需任何通知。 您應該只在程式碼中直接使用它,並特別小心,並知道這麼做可能會導致應用程式在更新至新的 Entity Framework Core 版本時失敗。

ProcessModelFinalizing(IConventionModelBuilder, IConventionContext<IConventionModelBuilder>)

當模型完成時呼叫。

ProcessNavigationAdded(IConventionNavigationBuilder, IConventionContext<IConventionNavigationBuilder>)

在導覽新增至實體類型之後呼叫。

ProcessNavigationAdded(IConventionRelationshipBuilder, IConventionNavigation, IConventionContext<IConventionNavigation>)

在導覽新增至實體類型之後呼叫。

ProcessPropertyAdded(IConventionPropertyBuilder, IConventionContext<IConventionPropertyBuilder>)

在屬性新增至實體類型之後呼叫。

ProcessPropertyFieldChanged(IConventionPropertyBuilder, FieldInfo, FieldInfo, IConventionContext<FieldInfo>)

在屬性的支援欄位變更之後呼叫。

ProcessPropertyNullabilityChanged(IConventionPropertyBuilder, IConventionContext<IConventionPropertyBuilder>)

在屬性的可為 Null 性變更之後呼叫。

ProcessPropertyNullabilityChanged(IConventionPropertyBuilder, IConventionContext<Nullable<Boolean>>)

在屬性的可為 Null 性變更之後呼叫。

ProcessSkipNavigationForeignKeyChanged(IConventionSkipNavigationBuilder, IConventionForeignKey, IConventionForeignKey, IConventionContext<IConventionForeignKey>)

在略過巡覽反向變更之後呼叫。

ProcessSkipNavigationInverseChanged(IConventionSkipNavigationBuilder, IConventionSkipNavigation, IConventionSkipNavigation, IConventionContext<IConventionSkipNavigation>)

在略過巡覽反向變更之後呼叫。

適用於