IEntityType IEntityType Interface

Definition

Represents an entity type in an IModel.

public interface IEntityType : ITypeBase, IAnnotatable
Public Interface IEntityType
    Inherits ITypeBase

Properties

BaseType BaseType

Gets the base type of the entity. Returns null if this is not a derived type in an inheritance hierarchy.

IEntityType BaseType { get; }
ReadOnly Property BaseType As IEntityType

ClrType ClrType

Gets the CLR class that is used to represent instances of this type. Returns null if the type does not have a corresponding CLR class (known as a shadow type).

Shadow types are not currently supported in a model that is used at runtime with a DbContext. Therefore, shadow types will only exist in migration model snapshots, etc.

Type ClrType { get; }
ReadOnly Property ClrType As Type
Value
System.Type System.Type

Item[String] Item(String)

Gets the value annotation with the given name, returning null if it does not exist.

(Inherited from IAnnotatable)

Model Model

Gets the model that this type belongs to.

IModel Model { get; }
ReadOnly Property Model As IModel
Value
IModel IModel

Name Name

Gets the name of this type.

string Name { get; }
ReadOnly Property Name As String
Value
System.String System.String

Methods

FindAnnotation(String) FindAnnotation(String)

Gets the annotation with the given name, returning null if it does not exist.

(Inherited from IAnnotatable)

FindForeignKey(IReadOnlyList, IKey, IEntityType) FindForeignKey(IReadOnlyList(Of IProperty), IKey, IEntityType)

Gets the foreign key for the given properties that points to a given primary or alternate key. Returns null if no foreign key is found.

IForeignKey FindForeignKey(IReadOnlyList<IProperty> properties, IKey principalKey, IEntityType principalEntityType)
Function FindForeignKey(properties As IReadOnlyList(Of IProperty), principalKey As IKey, principalEntityType As IEntityType) As IForeignKey
Parameters
properties
System.Collections.Generic.IReadOnlyList<IProperty> System.Collections.Generic.IReadOnlyList(Of IProperty)

The properties that the foreign key is defined on.

principalKey
IKey IKey

The primary or alternate key that is referenced.

principalEntityType
IEntityType IEntityType

The entity type that the relationship targets. This may be different from the type that principalKey is defined on when the relationship targets a derived type in an inheritance hierarchy (since the key is defined on the base type of the hierarchy).

Returns

The foreign key, or null if none is defined.

FindIndex(IReadOnlyList) FindIndex(IReadOnlyList(Of IProperty))

Gets the index defined on the given properties. Returns null if no index is defined.

IIndex FindIndex(IReadOnlyList<IProperty> properties)
Function FindIndex(properties As IReadOnlyList(Of IProperty)) As IIndex
Parameters
properties
System.Collections.Generic.IReadOnlyList<IProperty> System.Collections.Generic.IReadOnlyList(Of IProperty)

The properties to find the index on.

Returns

The index, or null if none is found.

FindKey(IReadOnlyList) FindKey(IReadOnlyList(Of IProperty))

Gets the primary or alternate key that is defined on the given properties. Returns null if no key is defined for the given properties.

IKey FindKey(IReadOnlyList<IProperty> properties)
Function FindKey(properties As IReadOnlyList(Of IProperty)) As IKey
Parameters
properties
System.Collections.Generic.IReadOnlyList<IProperty> System.Collections.Generic.IReadOnlyList(Of IProperty)

The properties that make up the key.

Returns

The key, or null if none is defined.

FindPrimaryKey() FindPrimaryKey()

Gets primary key for this entity. Returns null if no primary key is defined.

To be a valid model, each entity type must have a primary key defined. Therefore, the primary key may be null while the model is being created, but will be present by the time the model is used with a DbContext.

IKey FindPrimaryKey()
Function FindPrimaryKey As IKey
Returns

The primary key, or null if none is defined.

FindProperty(String) FindProperty(String)

Gets the property with a given name. Returns null if no property with the given name is defined.

This API only finds scalar properties and does not find navigation properties. Use FindNavigation(IEntityType, String) to find a navigation property.

IProperty FindProperty(string name)
Function FindProperty(name As String) As IProperty
Parameters
name
System.String System.String

The name of the property.

Returns

The property, or null if none is found.

GetAnnotations() GetAnnotations()

Gets all annotations on the current object.

(Inherited from IAnnotatable)

GetForeignKeys() GetForeignKeys()

Gets the foreign keys defined on this entity.

IEnumerable<IForeignKey> GetForeignKeys()
Function GetForeignKeys As IEnumerable(Of IForeignKey)
Returns
System.Collections.Generic.IEnumerable<IForeignKey> System.Collections.Generic.IEnumerable(Of IForeignKey)

The foreign keys defined on this entity.

GetIndexes() GetIndexes()

Gets the indexes defined on this entity.

IEnumerable<IIndex> GetIndexes()
Function GetIndexes As IEnumerable(Of IIndex)
Returns
System.Collections.Generic.IEnumerable<IIndex> System.Collections.Generic.IEnumerable(Of IIndex)

The indexes defined on this entity.

GetKeys() GetKeys()

Gets the primary and alternate keys for this entity.

IEnumerable<IKey> GetKeys()
Function GetKeys As IEnumerable(Of IKey)
Returns
System.Collections.Generic.IEnumerable<IKey> System.Collections.Generic.IEnumerable(Of IKey)

The primary and alternate keys.

GetProperties() GetProperties()

Gets the properties defined on this entity.

This API only returns scalar properties and does not return navigation properties. Use GetNavigations(IEntityType) to get navigation properties.

IEnumerable<IProperty> GetProperties()
Function GetProperties As IEnumerable(Of IProperty)
Returns
System.Collections.Generic.IEnumerable<IProperty> System.Collections.Generic.IEnumerable(Of IProperty)

The properties defined on this entity.