EntityTypeExtensions EntityTypeExtensions Class

Extension methods for IEntityType.

Syntax

Declaration

public static class EntityTypeExtensionsPublic Module EntityTypeExtensions

Inheritance Hierarchy

  • System.Object
    System.Object
  • EntityTypeExtensions
    EntityTypeExtensions

Inherited Members

ToString(),
ToString(),
Equals(Object),
Equals(Object),
Equals(Object, Object),
Equals(Object, Object),
ReferenceEquals(Object, Object),
ReferenceEquals(Object, Object),
GetHashCode(),
GetHashCode(),
GetType(),
GetType(),
MemberwiseClone()
MemberwiseClone()

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 foreign keys defined on the given property. Only foreign keys that are defined on exactly the specified property are returned. Composite foreign keys that include the specified property are not returned.

Gets the foreign keys defined on the given properties. Only foreign keys that are defined on exactly the specified set of properties are returned.

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

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

Gets a navigation property on the given entity type. Returns null if no navigation property is found.

Gets a navigation property on the given entity type. Returns null if no navigation property is found.

Gets a property on the given entity type. Returns null if no property is found.

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

Gets the change tracking strategy being used for this entity type. This strategy indicates how the context detects changes to properties for an instance of the entity type.

Gets all types in the model that derive from a given entity type.

Gets all navigation properties on the given entity type.

Gets all foreign keys that target a given entity type (i.e. foreign keys where the given entity type is the principal).

Determines if an entity type derives from (or is the same as) a given entity type.

Gets the least derived type between the specified two.

Gets the root base type for a given entity type.

Methods

  • FindForeignKey(IEntityType, IProperty, IKey, IEntityType)
    FindForeignKey(IEntityType, 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.

    public static IForeignKey FindForeignKey(this IEntityType entityType, IProperty property, IKey principalKey, IEntityType principalEntityType)<ExtensionAttribute>
    Public Shared Function FindForeignKey(entityType As IEntityType, property As IProperty, principalKey As IKey, principalEntityType As IEntityType) As IForeignKey

    Parameters

    • entityType

      The entity type to find the foreign keys on.

    • property

      The property 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

  • FindForeignKeys(IEntityType, IProperty)
    FindForeignKeys(IEntityType, IProperty)

    Gets the foreign keys defined on the given property. Only foreign keys that are defined on exactly the specified property are returned. Composite foreign keys that include the specified property are not returned.

    public static IEnumerable<IForeignKey> FindForeignKeys(this IEntityType entityType, IProperty property)<ExtensionAttribute>
    Public Shared Function FindForeignKeys(entityType As IEntityType, property As IProperty) As IEnumerable(Of IForeignKey)

    Parameters

    Returns

    • System.Collections.Generic.IEnumerable<T><IForeignKey>
      System.Collections.Generic.IEnumerable<T>(Of IForeignKey)

      The foreign keys.

  • FindForeignKeys(IEntityType, IReadOnlyList<IProperty>)
    FindForeignKeys(IEntityType, IReadOnlyList(Of IProperty))

    Gets the foreign keys defined on the given properties. Only foreign keys that are defined on exactly the specified set of properties are returned.

    public static IEnumerable<IForeignKey> FindForeignKeys(this IEntityType entityType, IReadOnlyList<IProperty> properties)<ExtensionAttribute>
    Public Shared Function FindForeignKeys(entityType As IEntityType, properties As IReadOnlyList(Of IProperty)) As IEnumerable(Of IForeignKey)

    Parameters

    • entityType

      The entity type to find the foreign keys on.

    • properties
      System.Collections.Generic.IReadOnlyList<T><IProperty>
      System.Collections.Generic.IReadOnlyList<T>(Of IProperty)

      The properties to find the foreign keys on.

    Returns

    • System.Collections.Generic.IEnumerable<T><IForeignKey>
      System.Collections.Generic.IEnumerable<T>(Of IForeignKey)

      The foreign keys.

  • FindIndex(IEntityType, IProperty)
    FindIndex(IEntityType, IProperty)

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

    public static IIndex FindIndex(this IEntityType entityType, IProperty property)<ExtensionAttribute>
    Public Shared Function FindIndex(entityType As IEntityType, property As IProperty) As IIndex

    Parameters

    Returns

  • FindKey(IEntityType, IProperty)
    FindKey(IEntityType, IProperty)

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

    public static IKey FindKey(this IEntityType entityType, IProperty property)<ExtensionAttribute>
    Public Shared Function FindKey(entityType As IEntityType, property As IProperty) As IKey

    Parameters

    Returns

    • The key, or null if none is defined.

  • FindNavigation(IEntityType, PropertyInfo)
    FindNavigation(IEntityType, PropertyInfo)

    Gets a navigation property on the given entity type. Returns null if no navigation property is found.

    public static INavigation FindNavigation(this IEntityType entityType, PropertyInfo propertyInfo)<ExtensionAttribute>
    Public Shared Function FindNavigation(entityType As IEntityType, propertyInfo As PropertyInfo) As INavigation

    Parameters

    • entityType

      The entity type to find the navigation property on.

    • propertyInfo
      System.Reflection.PropertyInfo
      System.Reflection.PropertyInfo

      The navigation property on the entity class.

    Returns

  • FindNavigation(IEntityType, String)
    FindNavigation(IEntityType, String)

    Gets a navigation property on the given entity type. Returns null if no navigation property is found.

    public static INavigation FindNavigation(this IEntityType entityType, string name)<ExtensionAttribute>
    Public Shared Function FindNavigation(entityType As IEntityType, name As String) As INavigation

    Parameters

    • entityType

      The entity type to find the navigation property on.

    • name
      System.String
      System.String

      The name of the navigation property on the entity class.

    Returns

  • FindProperty(IEntityType, PropertyInfo)
    FindProperty(IEntityType, PropertyInfo)

    Gets a property on the given entity type. Returns null if no property is found.

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

    public static IProperty FindProperty(this IEntityType entityType, PropertyInfo propertyInfo)<ExtensionAttribute>
    Public Shared Function FindProperty(entityType As IEntityType, propertyInfo As PropertyInfo) As IProperty

    Parameters

    • entityType

      The entity type to find the property on.

    • propertyInfo
      System.Reflection.PropertyInfo
      System.Reflection.PropertyInfo

      The property on the entity class.

    Returns

  • GetChangeTrackingStrategy(IEntityType)
    GetChangeTrackingStrategy(IEntityType)

    Gets the change tracking strategy being used for this entity type. This strategy indicates how the context detects changes to properties for an instance of the entity type.

    public static ChangeTrackingStrategy GetChangeTrackingStrategy(this IEntityType entityType)<ExtensionAttribute>
    Public Shared Function GetChangeTrackingStrategy(entityType As IEntityType) As ChangeTrackingStrategy

    Parameters

    Returns

  • GetDerivedTypes(IEntityType)
    GetDerivedTypes(IEntityType)

    Gets all types in the model that derive from a given entity type.

    public static IEnumerable<IEntityType> GetDerivedTypes(this IEntityType entityType)<ExtensionAttribute>
    Public Shared Function GetDerivedTypes(entityType As IEntityType) As IEnumerable(Of IEntityType)

    Parameters

    Returns

    • System.Collections.Generic.IEnumerable<T><IEntityType>
      System.Collections.Generic.IEnumerable<T>(Of IEntityType)

      The derived types.

  • GetNavigations(IEntityType)
    GetNavigations(IEntityType)

    Gets all navigation properties on the given entity type.

    public static IEnumerable<INavigation> GetNavigations(this IEntityType entityType)<ExtensionAttribute>
    Public Shared Function GetNavigations(entityType As IEntityType) As IEnumerable(Of INavigation)

    Parameters

    Returns

    • System.Collections.Generic.IEnumerable<T><INavigation>
      System.Collections.Generic.IEnumerable<T>(Of INavigation)

      All navigation properties on the given entity type.

  • GetReferencingForeignKeys(IEntityType)
    GetReferencingForeignKeys(IEntityType)

    Gets all foreign keys that target a given entity type (i.e. foreign keys where the given entity type is the principal).

    public static IEnumerable<IForeignKey> GetReferencingForeignKeys(this IEntityType entityType)<ExtensionAttribute>
    Public Shared Function GetReferencingForeignKeys(entityType As IEntityType) As IEnumerable(Of IForeignKey)

    Parameters

    Returns

    • System.Collections.Generic.IEnumerable<T><IForeignKey>
      System.Collections.Generic.IEnumerable<T>(Of IForeignKey)

      The foreign keys that reference the given entity type.

  • IsAssignableFrom(IEntityType, IEntityType)
    IsAssignableFrom(IEntityType, IEntityType)

    Determines if an entity type derives from (or is the same as) a given entity type.

    public static bool IsAssignableFrom(this IEntityType entityType, IEntityType derivedType)<ExtensionAttribute>
    Public Shared Function IsAssignableFrom(entityType As IEntityType, derivedType As IEntityType) As Boolean

    Parameters

    Returns

    • System.Boolean
      System.Boolean

      True if derivedType derives from (or is the same as) entityType, otherwise false.

  • LeastDerivedType(IEntityType, IEntityType)
    LeastDerivedType(IEntityType, IEntityType)

    Gets the least derived type between the specified two.

    public static IEntityType LeastDerivedType(this IEntityType entityType, IEntityType otherEntityType)<ExtensionAttribute>
    Public Shared Function LeastDerivedType(entityType As IEntityType, otherEntityType As IEntityType) As IEntityType

    Parameters

    Returns

    • The least derived type between the specified two. If the given entity types are not related, then null is returned.

  • RootType(IEntityType)
    RootType(IEntityType)

    Gets the root base type for a given entity type.

    public static IEntityType RootType(this IEntityType entityType)<ExtensionAttribute>
    Public Shared Function RootType(entityType As IEntityType) As IEntityType

    Parameters

    Returns

    • The root base type. If the given entity type is not a derived type, then the same entity type is returned.

Details

Assembly

Microsoft.EntityFrameworkCore.dll