Compartilhar via


ModelBuilder.Entity Method

Definition

Overloads

Entity(Type, Action<EntityTypeBuilder>)

Performs configuration of a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

Entity(String, Action<EntityTypeBuilder>)

Performs configuration of a given entity type in the model. If an entity type with the provided name is not already part of the model, a new entity type that does not have a corresponding CLR type will be added to the model.

Entity(Type)

Returns an object that can be used to configure a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

Entity(String)

Returns an object that can be used to configure a given entity type in the model. If an entity type with the provided name is not already part of the model, a new entity type that does not have a corresponding CLR type will be added to the model.

Entity<TEntity>()

Returns an object that can be used to configure a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

Entity<TEntity>(Action<EntityTypeBuilder<TEntity>>)

Performs configuration of a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

Entity(Type, Action<EntityTypeBuilder>)

Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs

Performs configuration of a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

public virtual Microsoft.EntityFrameworkCore.ModelBuilder Entity (Type type, Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder> buildAction);
abstract member Entity : Type * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder> -> Microsoft.EntityFrameworkCore.ModelBuilder
override this.Entity : Type * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder> -> Microsoft.EntityFrameworkCore.ModelBuilder
Public Overridable Function Entity (type As Type, buildAction As Action(Of EntityTypeBuilder)) As ModelBuilder

Parameters

type
Type

The entity type to be configured.

buildAction
Action<EntityTypeBuilder>

An action that performs configuration of the entity type.

Returns

The same ModelBuilder instance so that additional configuration calls can be chained.

Remarks

This overload allows configuration of the entity type to be done in line in the method call rather than being chained after a call to Entity<TEntity>(). This allows additional configuration at the model level to be chained after configuration for the entity type.

See Modeling entity types for more information and examples.

Applies to

Entity(String, Action<EntityTypeBuilder>)

Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs

Performs configuration of a given entity type in the model. If an entity type with the provided name is not already part of the model, a new entity type that does not have a corresponding CLR type will be added to the model.

public virtual Microsoft.EntityFrameworkCore.ModelBuilder Entity (string name, Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder> buildAction);
abstract member Entity : string * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder> -> Microsoft.EntityFrameworkCore.ModelBuilder
override this.Entity : string * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder> -> Microsoft.EntityFrameworkCore.ModelBuilder
Public Overridable Function Entity (name As String, buildAction As Action(Of EntityTypeBuilder)) As ModelBuilder

Parameters

name
String

The name of the entity type to be configured.

buildAction
Action<EntityTypeBuilder>

An action that performs configuration of the entity type.

Returns

The same ModelBuilder instance so that additional configuration calls can be chained.

Remarks

This overload allows configuration of the entity type to be done in line in the method call rather than being chained after a call to Entity(String). This allows additional configuration at the model level to be chained after configuration for the entity type.

See Modeling entity types for more information and examples.

Applies to

Entity(Type)

Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs

Returns an object that can be used to configure a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder Entity (Type type);
abstract member Entity : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder
override this.Entity : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder
Public Overridable Function Entity (type As Type) As EntityTypeBuilder

Parameters

type
Type

The entity type to be configured.

Returns

An object that can be used to configure the entity type.

Remarks

See Modeling entity types for more information and examples.

Applies to

Entity(String)

Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs

Returns an object that can be used to configure a given entity type in the model. If an entity type with the provided name is not already part of the model, a new entity type that does not have a corresponding CLR type will be added to the model.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder Entity (string name);
abstract member Entity : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder
override this.Entity : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder
Public Overridable Function Entity (name As String) As EntityTypeBuilder

Parameters

name
String

The name of the entity type to be configured.

Returns

An object that can be used to configure the entity type.

Remarks

See Modeling entity types for more information and examples.

Applies to

Entity<TEntity>()

Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs

Returns an object that can be used to configure a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity> Entity<TEntity> () where TEntity : class;
abstract member Entity : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.Entity : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Overridable Function Entity(Of TEntity As Class) () As EntityTypeBuilder(Of TEntity)

Type Parameters

TEntity

The entity type to be configured.

Returns

An object that can be used to configure the entity type.

Remarks

See Modeling entity types for more information and examples.

Applies to

Entity<TEntity>(Action<EntityTypeBuilder<TEntity>>)

Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs
Source:
ModelBuilder.cs

Performs configuration of a given entity type in the model. If the entity type is not already part of the model, it will be added to the model.

public virtual Microsoft.EntityFrameworkCore.ModelBuilder Entity<TEntity> (Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity>> buildAction) where TEntity : class;
abstract member Entity : Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity>> -> Microsoft.EntityFrameworkCore.ModelBuilder (requires 'Entity : null)
override this.Entity : Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity>> -> Microsoft.EntityFrameworkCore.ModelBuilder (requires 'Entity : null)
Public Overridable Function Entity(Of TEntity As Class) (buildAction As Action(Of EntityTypeBuilder(Of TEntity))) As ModelBuilder

Type Parameters

TEntity

The entity type to be configured.

Parameters

buildAction
Action<EntityTypeBuilder<TEntity>>

An action that performs configuration of the entity type.

Returns

The same ModelBuilder instance so that additional configuration calls can be chained.

Remarks

This overload allows configuration of the entity type to be done in line in the method call rather than being chained after a call to Entity<TEntity>(). This allows additional configuration at the model level to be chained after configuration for the entity type.

See Modeling entity types for more information and examples.

Applies to