RuntimeModel.AddEntityType 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
AddEntityType(String, Type, RuntimeEntityType, Boolean, String, ChangeTrackingStrategy, PropertyInfo, Boolean)
將具有定義導覽的實體類型新增至模型。
public virtual Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType AddEntityType (string name, Type type, Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType? baseType = default, bool sharedClrType = false, string? discriminatorProperty = default, Microsoft.EntityFrameworkCore.ChangeTrackingStrategy changeTrackingStrategy = Microsoft.EntityFrameworkCore.ChangeTrackingStrategy.Snapshot, System.Reflection.PropertyInfo? indexerPropertyInfo = default, bool propertyBag = false);
abstract member AddEntityType : string * Type * Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType * bool * string * Microsoft.EntityFrameworkCore.ChangeTrackingStrategy * System.Reflection.PropertyInfo * bool -> Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType
override this.AddEntityType : string * Type * Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType * bool * string * Microsoft.EntityFrameworkCore.ChangeTrackingStrategy * System.Reflection.PropertyInfo * bool -> Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType
Public Overridable Function AddEntityType (name As String, type As Type, Optional baseType As RuntimeEntityType = Nothing, Optional sharedClrType As Boolean = false, Optional discriminatorProperty As String = Nothing, Optional changeTrackingStrategy As ChangeTrackingStrategy = Microsoft.EntityFrameworkCore.ChangeTrackingStrategy.Snapshot, Optional indexerPropertyInfo As PropertyInfo = Nothing, Optional propertyBag As Boolean = false) As RuntimeEntityType
參數
- name
- String
要加入之實體類型的名稱。
- type
- Type
用來表示此型別實例的 CLR 類別。
- baseType
- RuntimeEntityType
此實體類型的基底類型。
- sharedClrType
- Boolean
此實體類型是否可以與其他實體共用其 ClrType。
- discriminatorProperty
- String
將用於儲存鑒別子值的屬性名稱。
- changeTrackingStrategy
- ChangeTrackingStrategy
此實體類型的變更追蹤策略
- indexerPropertyInfo
- PropertyInfo
PropertyInfo如果存在,則為相關聯 CLR 型別上索引子的 。
- propertyBag
- Boolean
值,指出這個實體類型是否有索引子,其能夠包含任意屬性,以及可用來判斷指定索引子屬性是否包含值的方法。
傳回
新的實體類型。
適用於
AddEntityType(String, Type, RuntimeEntityType, Boolean, String, ChangeTrackingStrategy, PropertyInfo, Boolean, Object)
將具有定義導覽的實體類型新增至模型。
public virtual Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType AddEntityType (string name, Type type, Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType? baseType = default, bool sharedClrType = false, string? discriminatorProperty = default, Microsoft.EntityFrameworkCore.ChangeTrackingStrategy changeTrackingStrategy = Microsoft.EntityFrameworkCore.ChangeTrackingStrategy.Snapshot, System.Reflection.PropertyInfo? indexerPropertyInfo = default, bool propertyBag = false, object? discriminatorValue = default);
abstract member AddEntityType : string * Type * Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType * bool * string * Microsoft.EntityFrameworkCore.ChangeTrackingStrategy * System.Reflection.PropertyInfo * bool * obj -> Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType
override this.AddEntityType : string * Type * Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType * bool * string * Microsoft.EntityFrameworkCore.ChangeTrackingStrategy * System.Reflection.PropertyInfo * bool * obj -> Microsoft.EntityFrameworkCore.Metadata.RuntimeEntityType
Public Overridable Function AddEntityType (name As String, type As Type, Optional baseType As RuntimeEntityType = Nothing, Optional sharedClrType As Boolean = false, Optional discriminatorProperty As String = Nothing, Optional changeTrackingStrategy As ChangeTrackingStrategy = Microsoft.EntityFrameworkCore.ChangeTrackingStrategy.Snapshot, Optional indexerPropertyInfo As PropertyInfo = Nothing, Optional propertyBag As Boolean = false, Optional discriminatorValue As Object = Nothing) As RuntimeEntityType
參數
- name
- String
要加入之實體類型的名稱。
- type
- Type
用來表示此型別實例的 CLR 類別。
- baseType
- RuntimeEntityType
此實體類型的基底類型。
- sharedClrType
- Boolean
此實體類型是否可以與其他實體共用其 ClrType。
- discriminatorProperty
- String
將用於儲存鑒別子值的屬性名稱。
- changeTrackingStrategy
- ChangeTrackingStrategy
此實體類型的變更追蹤策略。
- indexerPropertyInfo
- PropertyInfo
PropertyInfo如果存在,則為相關聯 CLR 型別上索引子的 。
- propertyBag
- Boolean
值,指出這個實體類型是否有索引子,其能夠包含任意屬性,以及可用來判斷指定索引子屬性是否包含值的方法。
- discriminatorValue
- Object
這個實體類型的鑒別子值。
傳回
新的實體類型。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應