IEntityType IEntityType Interface

Represents an entity type in an IModel.

Syntax

Declaration

public interface IEntityType : ITypeBase, IAnnotatablePublic Interface IEntityType
    Inherits ITypeBase

Inherited Members

Item[String],
Item(String),
FindAnnotation(String),
FindAnnotation(String),
GetAnnotations()
GetAnnotations()

Properties summary

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

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.

Gets the model that this type belongs to.

Gets the name of this type.

Methods summary

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.

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

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

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.

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.

Gets the foreign keys defined on this entity.

Gets the indexes defined on this entity.

Gets the primary and alternate keys for this entity.

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.

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

    Property Value

  • 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

    Property Value

    • System.Type
      System.Type
  • Model
    Model

    Gets the model that this type belongs to.

    IModel Model { get; }ReadOnly Property Model As IModel

    Property Value

  • Name
    Name

    Gets the name of this type.

    string Name { get; }ReadOnly Property Name As String

    Property Value

    • System.String
      System.String

Methods

  • FindForeignKey(IReadOnlyList<IProperty>, 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<T><IProperty>
      System.Collections.Generic.IReadOnlyList<T>(Of IProperty)

      The properties that the foreign key is defined on.

    • principalKey

      The primary or alternate key that is referenced.

    • principalEntityType

      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

  • FindIndex(IReadOnlyList<IProperty>)
    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<T><IProperty>
      System.Collections.Generic.IReadOnlyList<T>(Of IProperty)

      The properties to find the index on.

    Returns

  • FindKey(IReadOnlyList<IProperty>)
    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<T><IProperty>
      System.Collections.Generic.IReadOnlyList<T>(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

  • GetForeignKeys()
    GetForeignKeys()

    Gets the foreign keys defined on this entity.

    IEnumerable<IForeignKey> GetForeignKeys()Function GetForeignKeys As IEnumerable(Of IForeignKey)

    Returns

    • System.Collections.Generic.IEnumerable<T><IForeignKey>
      System.Collections.Generic.IEnumerable<T>(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<T><IIndex>
      System.Collections.Generic.IEnumerable<T>(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<T><IKey>
      System.Collections.Generic.IEnumerable<T>(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<T><IProperty>
      System.Collections.Generic.IEnumerable<T>(Of IProperty)

      The properties defined on this entity.

Details

Assembly

Microsoft.EntityFrameworkCore.dll