IConventionModel.AddEntityType Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddEntityType(String, Boolean) |
Adds a state entity type of default type to the model. |
AddEntityType(String, Type, Boolean) |
Adds a shared type entity type to the model. |
AddEntityType(Type, Boolean) |
Adds an entity type to the model. |
AddEntityType(String, String, IConventionEntityType, Boolean) |
Adds an owned entity type with a defining navigation to the model. |
AddEntityType(Type, String, IConventionEntityType, Boolean) |
Adds an owned entity type with a defining navigation to the model. |
AddEntityType(String, Boolean)
Adds a state entity type of default type to the model.
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
Parameters
- name
- String
The name of the entity to be added.
- fromDataAnnotation
- Boolean
Indicates whether the configuration was specified using a data annotation.
Returns
The new entity type.
Remarks
Shadow entities are not currently supported in a model that is used at runtime with a DbContext. Therefore, shadow state entity types will only exist in migration model snapshots, etc.
Applies to
AddEntityType(String, Type, Boolean)
Adds a shared type entity type to the model.
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
Parameters
- name
- String
The name of the entity to be added.
- clrType
- Type
The CLR class that is used to represent instances of the entity type.
- fromDataAnnotation
- Boolean
Indicates whether the configuration was specified using a data annotation.
Returns
The new entity type.
Remarks
Shared type entity type is an entity type which can share CLR type with other types in the model but has a unique name and always identified by the name.
Applies to
AddEntityType(Type, Boolean)
Adds an entity type to the model.
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
Parameters
- clrTypetype
- Type
The CLR class that is used to represent instances of the entity type.
- fromDataAnnotation
- Boolean
Indicates whether the configuration was specified using a data annotation.
Returns
The new entity type.
Applies to
AddEntityType(String, String, IConventionEntityType, Boolean)
Adds an owned entity type with a defining navigation to the model.
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
Parameters
- name
- String
The name of the entity type to be added.
- definingNavigationName
- String
The defining navigation.
- definingEntityType
- IConventionEntityType
The defining entity type.
- fromDataAnnotation
- Boolean
Indicates whether the configuration was specified using a data annotation.
Returns
The new entity type.
Applies to
AddEntityType(Type, String, IConventionEntityType, Boolean)
Adds an owned entity type with a defining navigation to the model.
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
Parameters
- clrTypetype
- Type
The CLR class that is used to represent instances of this entity type.
- definingNavigationName
- String
The defining navigation.
- definingEntityType
- IConventionEntityType
The defining entity type.
- fromDataAnnotation
- Boolean
Indicates whether the configuration was specified using a data annotation.
Returns
The new entity type.
Applies to
Entity Framework