IConventionModel.AddEntityType 方法

定义

重载

AddEntityType(String, Boolean)

将默认类型的状态实体类型添加到模型。

AddEntityType(String, Type, Boolean)

将共享类型实体类型添加到模型。

AddEntityType(Type, Boolean)

将实体类型添加到模型。

AddEntityType(String, String, IConventionEntityType, Boolean)

将具有定义导航的自有实体类型添加到模型。

AddEntityType(Type, String, IConventionEntityType, Boolean)

将具有定义导航的自有实体类型添加到模型。

AddEntityType(String, Boolean)

将默认类型的状态实体类型添加到模型。

public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType AddEntityType (string name, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType (string name, bool fromDataAnnotation = false);
abstract member AddEntityType : string * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType
Public Function AddEntityType (name As String, Optional fromDataAnnotation As Boolean = false) As IConventionEntityType

参数

name
String

要添加的实体的名称。

fromDataAnnotation
Boolean

指示是否使用数据注释指定配置。

返回

新的实体类型。

注解

在运行时与 一起使用 DbContext的模型中,当前不支持影子实体。 因此,影子状态实体类型将仅存在于迁移模型快照等中。

适用于

AddEntityType(String, Type, Boolean)

将共享类型实体类型添加到模型。

public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType AddEntityType (string name, Type clrType, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType (string name, Type clrType, bool fromDataAnnotation = false);
abstract member AddEntityType : string * Type * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType
Public Function AddEntityType (name As String, clrType As Type, Optional fromDataAnnotation As Boolean = false) As IConventionEntityType

参数

name
String

要添加的实体的名称。

clrType
Type

用于表示实体类型的实例的 CLR 类。

fromDataAnnotation
Boolean

指示是否使用数据注释指定配置。

返回

新的实体类型。

注解

共享类型实体类型是一种实体类型,它可以与模型中的其他类型共享 CLR 类型,但具有唯一的名称,并且始终由名称标识。

适用于

AddEntityType(Type, Boolean)

将实体类型添加到模型。

public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType AddEntityType (Type clrType, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType AddEntityType (Type type, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType (Type type, bool fromDataAnnotation = false);
abstract member AddEntityType : Type * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType
abstract member AddEntityType : Type * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType
Public Function AddEntityType (clrType As Type, Optional fromDataAnnotation As Boolean = false) As IConventionEntityType
Public Function AddEntityType (type As Type, Optional fromDataAnnotation As Boolean = false) As IConventionEntityType

参数

clrTypetype
Type

用于表示实体类型的实例的 CLR 类。

fromDataAnnotation
Boolean

指示是否使用数据注释指定配置。

返回

新的实体类型。

适用于

AddEntityType(String, String, IConventionEntityType, Boolean)

将具有定义导航的自有实体类型添加到模型。

public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType AddEntityType (string name, string definingNavigationName, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType definingEntityType, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType (string name, string definingNavigationName, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType definingEntityType, bool fromDataAnnotation = false);
abstract member AddEntityType : string * string * Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType
Public Function AddEntityType (name As String, definingNavigationName As String, definingEntityType As IConventionEntityType, Optional fromDataAnnotation As Boolean = false) As IConventionEntityType

参数

name
String

要添加的实体类型的名称。

definingNavigationName
String

定义导航。

definingEntityType
IConventionEntityType

定义实体类型。

fromDataAnnotation
Boolean

指示是否使用数据注释指定配置。

返回

新的实体类型。

适用于

AddEntityType(Type, String, IConventionEntityType, Boolean)

将具有定义导航的自有实体类型添加到模型。

public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType AddEntityType (Type clrType, string definingNavigationName, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType definingEntityType, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType AddEntityType (Type type, string definingNavigationName, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType definingEntityType, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType? AddEntityType (Type type, string definingNavigationName, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType definingEntityType, bool fromDataAnnotation = false);
abstract member AddEntityType : Type * string * Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType
abstract member AddEntityType : Type * string * Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType
Public Function AddEntityType (clrType As Type, definingNavigationName As String, definingEntityType As IConventionEntityType, Optional fromDataAnnotation As Boolean = false) As IConventionEntityType
Public Function AddEntityType (type As Type, definingNavigationName As String, definingEntityType As IConventionEntityType, Optional fromDataAnnotation As Boolean = false) As IConventionEntityType

参数

clrTypetype
Type

用于表示此实体类型的实例的 CLR 类。

definingNavigationName
String

定义导航。

definingEntityType
IConventionEntityType

定义实体类型。

fromDataAnnotation
Boolean

指示是否使用数据注释指定配置。

返回

新的实体类型。

适用于