閱讀英文版本

分享方式:


ValueGenerationConvention 類別

定義

慣例,會將儲存值產生設定為 OnAdd 主鍵一部分的屬性,而不是任何外鍵的一部分。

C#
public class ValueGenerationConvention : Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypeBaseTypeChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypePrimaryKeyChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyPropertiesChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyRemovedConvention
C#
public class ValueGenerationConvention : Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypeBaseTypeChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IEntityTypePrimaryKeyChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyAddedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyOwnershipChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyPropertiesChangedConvention, Microsoft.EntityFrameworkCore.Metadata.Conventions.IForeignKeyRemovedConvention
繼承
ValueGenerationConvention
衍生
實作

備註

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

建構函式

屬性

Dependencies

此服務的相依性。

方法

GetValueGenerated(IConventionProperty)

傳回為指定屬性設定的存放區值產生策略。

GetValueGenerated(IProperty)

傳回為指定屬性設定的存放區值產生策略。

GetValueGenerated(IReadOnlyProperty)

傳回為指定屬性設定的存放區值產生策略。

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

在實體類型的基底類型變更之後呼叫。

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

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

ProcessForeignKeyAdded(IConventionForeignKeyBuilder, IConventionContext<IConventionForeignKeyBuilder>)

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

ProcessForeignKeyAdded(IConventionRelationshipBuilder, IConventionContext<IConventionRelationshipBuilder>)

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

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

在外鍵的擁有權值變更之後呼叫。

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

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

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

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

ProcessForeignKeyRemoved(IConventionEntityTypeBuilder, IConventionForeignKey, IConventionContext<IConventionForeignKey>)

移除外鍵之後呼叫。

適用於

產品 版本
Entity Framework Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0