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>)

在跳过导航逆向更改后调用。

适用于