EntityTypeBuilder<TEntity> EntityTypeBuilder(Of TEntity) Class

Definition

Provides a simple API for configuring an EntityType.

Instances of this class are returned from methods when using the ModelBuilder API and it is not designed to be directly constructed in your application code.

public class EntityTypeBuilder<TEntity> : EntityTypeBuilder, IInfrastructure<IMutableModel>, IInfrastructure<InternalEntityTypeBuilder> where TEntity : class
Public Class EntityTypeBuilder(Of TEntity As Class)
    Inherits EntityTypeBuilder
    Implements IInfrastructure(Of IMutableModel), IInfrastructure(Of InternalEntityTypeBuilder)

Type Parameters

TEntity

The entity type being configured.

Inheritance
System.ObjectSystem.Object
EntityTypeBuilder<TEntity>EntityTypeBuilder(Of TEntity)
Implements

Constructors

EntityTypeBuilder(InternalEntityTypeBuilder) EntityTypeBuilder(InternalEntityTypeBuilder)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

Methods

System.Object.Equals(System.Object) System.Object.Equals(System.Object) Inherited from System.Object
System.Object.Equals(System.Object, System.Object) System.Object.Equals(System.Object, System.Object) Inherited from System.Object
System.Object.GetHashCode() System.Object.GetHashCode() Inherited from System.Object
System.Object.GetType() System.Object.GetType() Inherited from System.Object
HasAlternateKey(Expression<Func<TEntity, Object>>) HasAlternateKey(Expression(Of Func(Of TEntity, Object)))

Creates a new unique constraint for this entity type if one does not already exist over the specified properties.

HasAlternateKey(String[]) HasAlternateKey(String())

Creates a new unique constraint for this entity type if one does not already exist over the specified properties.

(Inherited from EntityTypeBuilder)
HasAnnotation(String, Object) HasAnnotation(String, Object)

Adds or updates an annotation on the entity type. If an annotation with the key specified in annotation already exists it's value will be updated.

HasBaseType(String) HasBaseType(String)

Sets the base type of this entity in an inheritance hierarchy.

HasBaseType(Type) HasBaseType(Type)

Sets the base type of this entity in an inheritance hierarchy.

HasBaseType<TBaseType>() HasBaseType(Of TBaseType)()

Sets the base type of this entity in an inheritance hierarchy.

HasChangeTrackingStrategy(ChangeTrackingStrategy) HasChangeTrackingStrategy(ChangeTrackingStrategy)

Configures the ChangeTrackingStrategy to be used for this entity type. This strategy indicates how the context detects changes to properties for an instance of the entity type.

HasIndex(Expression<Func<TEntity, Object>>) HasIndex(Expression(Of Func(Of TEntity, Object)))

Configures an index on the specified properties. If there is an existing index on the given set of properties, then the existing index will be returned for configuration.

HasIndex(String[]) HasIndex(String())

Configures an index on the specified properties. If there is an existing index on the given set of properties, then the existing index will be returned for configuration.

(Inherited from EntityTypeBuilder)
HasKey(Expression<Func<TEntity, Object>>) HasKey(Expression(Of Func(Of TEntity, Object)))

Sets the properties that make up the primary key for this entity type.

HasKey(String[]) HasKey(String())

Sets the properties that make up the primary key for this entity type.

(Inherited from EntityTypeBuilder)
HasMany(String, String) HasMany(String, String)

Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship.

After calling this method, you should chain a call to WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

(Inherited from EntityTypeBuilder)
HasMany(Type, String) HasMany(Type, String)

Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship.

After calling this method, you should chain a call to WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

(Inherited from EntityTypeBuilder)
HasMany<TRelatedEntity>(Expression<Func<TEntity, IEnumerable<TRelatedEntity>>>) HasMany(Of TRelatedEntity)(Expression(Of Func(Of TEntity, IEnumerable(Of TRelatedEntity))))

Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship.

After calling this method, you should chain a call to WithOne(Expression<Func<TRelatedEntity, TEntity>>) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

HasManyBuilder(EntityType, PropertyInfo) HasManyBuilder(EntityType, PropertyInfo)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

(Inherited from EntityTypeBuilder)
HasManyBuilder(EntityType, String) HasManyBuilder(EntityType, String)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

(Inherited from EntityTypeBuilder)
HasOne(String, String) HasOne(String, String)

Configures a relationship where this entity type has a reference that points to a single instance of the other type in the relationship.

After calling this method, you should chain a call to WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

(Inherited from EntityTypeBuilder)
HasOne(Type, String) HasOne(Type, String)

Configures a relationship where this entity type has a reference that points to a single instance of the other type in the relationship.

After calling this method, you should chain a call to WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

(Inherited from EntityTypeBuilder)
HasOne<TRelatedEntity>(Expression<Func<TEntity, TRelatedEntity>>) HasOne(Of TRelatedEntity)(Expression(Of Func(Of TEntity, TRelatedEntity)))

Configures a relationship where this entity type has a reference that points to a single instance of the other type in the relationship.

After calling this method, you should chain a call to WithMany(Expression<Func<TRelatedEntity, IEnumerable<TEntity>>>) or WithOne(Expression<Func<TRelatedEntity, TEntity>>) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

HasOneBuilder(EntityType, PropertyInfo) HasOneBuilder(EntityType, PropertyInfo)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

(Inherited from EntityTypeBuilder)
HasOneBuilder(EntityType, String) HasOneBuilder(EntityType, String)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

(Inherited from EntityTypeBuilder)
Ignore(Expression<Func<TEntity, Object>>) Ignore(Expression(Of Func(Of TEntity, Object)))

Excludes the given property from the entity type. This method is typically used to remove properties from the entity type that were added by convention.

Ignore(String) Ignore(String)

Excludes the given property from the entity type. This method is typically used to remove properties from the entity type that were added by convention.

System.Object.MemberwiseClone() System.Object.MemberwiseClone() Inherited from System.Object
New(InternalEntityTypeBuilder) New(InternalEntityTypeBuilder)

Creates a new builder based on the provided internal builder. This overridden implementation creates EntityTypeBuilder<TEntity> instances so that logic inherited from the base class will use those instead of EntityTypeBuilder.

Property(String) Property(String)

Returns an object that can be used to configure a property of the entity type. If no property with the given name exists, then a new property will be added.

When adding a new property with this overload the property name must match the name of a CLR property or field on the entity type. This overload cannot be used to add a new shadow state property.

(Inherited from EntityTypeBuilder)
Property(Type, String) Property(Type, String)

Returns an object that can be used to configure a property of the entity type. If no property with the given name exists, then a new property will be added.

When adding a new property, if a property with the same name exists in the entity class then it will be added to the model. If no property exists in the entity class, then a new shadow state property will be added. A shadow state property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

(Inherited from EntityTypeBuilder)
Property<TProperty>(Expression<Func<TEntity, TProperty>>) Property(Of TProperty)(Expression(Of Func(Of TEntity, TProperty)))

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

Property<TProperty>(String) Property(Of TProperty)(String)

Returns an object that can be used to configure a property of the entity type. If no property with the given name exists, then a new property will be added.

When adding a new property, if a property with the same name exists in the entity class then it will be added to the model. If no property exists in the entity class, then a new shadow state property will be added. A shadow state property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

(Inherited from EntityTypeBuilder)
System.Object.ReferenceEquals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) Inherited from System.Object
System.Object.ToString() System.Object.ToString() Inherited from System.Object
UsePropertyAccessMode(PropertyAccessMode) UsePropertyAccessMode(PropertyAccessMode)

Sets the PropertyAccessMode to use for all properties of this entity type.

By default, the backing field, if one is found by convention or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. Calling this method witll change that behavior for all properties of this entity type as described in the PropertyAccessMode enum.

Calling this method overrrides for all properties of this entity type any access mode that was set on the model.

Properties

IInfrastructure<IMutableModel>.Instance Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.IMutableModel>.Instance

The model that the entity type belongs to.

(Inherited from EntityTypeBuilder)
IInfrastructure<InternalEntityTypeBuilder>.Instance Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder>.Instance

Gets the internal builder being used to configure the entity type.

(Inherited from EntityTypeBuilder)
Metadata Metadata

The entity type being configured.

(Inherited from EntityTypeBuilder)

Extension Methods

Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable(System.String) Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable(System.String)
Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable<TEntity>(System.String) Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable(Of TEntity)(System.String)
Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable(System.String, System.String) Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable(System.String, System.String)
Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable<TEntity>(System.String, System.String) Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerToTable(Of TEntity)(System.String, System.String)
Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerIsMemoryOptimized(System.Boolean) Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerIsMemoryOptimized(System.Boolean)
Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerIsMemoryOptimized<TEntity>(System.Boolean) Microsoft.EntityFrameworkCore.SqlServerEntityTypeBuilderExtensions.ForSqlServerIsMemoryOptimized(Of TEntity)(System.Boolean)
Microsoft.EntityFrameworkCore.SqliteEntityTypeBuilderExtensions.ForSqliteToTable(System.String) Microsoft.EntityFrameworkCore.SqliteEntityTypeBuilderExtensions.ForSqliteToTable(System.String)
Microsoft.EntityFrameworkCore.SqliteEntityTypeBuilderExtensions.ForSqliteToTable<TEntity>(System.String) Microsoft.EntityFrameworkCore.SqliteEntityTypeBuilderExtensions.ForSqliteToTable(Of TEntity)(System.String)
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable(System.String) Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable(System.String)
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable<TEntity>(System.String) Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable(Of TEntity)(System.String)
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable(System.String, System.String) Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable(System.String, System.String)
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable<TEntity>(System.String, System.String) Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.ToTable(Of TEntity)(System.String, System.String)
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator() Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator()
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator(System.String, System.Type) Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator(System.String, System.Type)
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator<TDiscriminator>(System.String) Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator(Of TDiscriminator)(System.String)
Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator<TEntity, TDiscriminator>(System.Linq.Expressions.Expression<System.Func<TEntity, TDiscriminator>>) Microsoft.EntityFrameworkCore.RelationalEntityTypeBuilderExtensions.HasDiscriminator(Of TEntity, TDiscriminator)(System.Linq.Expressions.Expression(Of System.Func(Of TEntity, TDiscriminator)))