EntityTypeExtensions EntityTypeExtensions Class

Definition

Extension methods for IEntityType.

public static class EntityTypeExtensions
Public Module EntityTypeExtensions
Inheritance
System.ObjectSystem.Object
EntityTypeExtensionsEntityTypeExtensions

Inherited Members

System.Object

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

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
IEntityType IEntityType

The entity type to find the foreign keys on.

property
IProperty IProperty

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

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
entityType
IEntityType IEntityType

The entity type to find the foreign keys on.

property
IProperty IProperty

The property to find the foreign keys on.

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

The foreign keys.

FindForeignKeys(IEntityType, IReadOnlyList) 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
IEntityType IEntityType

The entity type to find the foreign keys on.

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

The properties to find the foreign keys on.

Returns
System.Collections.Generic.IEnumerable<IForeignKey> System.Collections.Generic.IEnumerable(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
entityType
IEntityType IEntityType

The entity type to find the index on.

property
IProperty IProperty

The property to find the index on.

Returns

The index, or null if none is found.

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
entityType
IEntityType IEntityType

The entity type to find the key on.

property
IProperty IProperty

The property that the key is defined on.

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
IEntityType IEntityType

The entity type to find the navigation property on.

propertyInfo
System.Reflection.PropertyInfo System.Reflection.PropertyInfo

The navigation property on the entity class.

Returns

The navigation property, or null if none is found.

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
IEntityType IEntityType

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

The navigation property, or null if none is found.

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
IEntityType IEntityType

The entity type to find the property on.

propertyInfo
System.Reflection.PropertyInfo System.Reflection.PropertyInfo

The property on the entity class.

Returns

The property, or null if none is found.

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
entityType
IEntityType IEntityType

The entity type to get the change tracking strategy for.

Returns

The change tracking strategy.

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
entityType
IEntityType IEntityType

The base type to find types that derive from.

Returns
System.Collections.Generic.IEnumerable<IEntityType> System.Collections.Generic.IEnumerable(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
entityType
IEntityType IEntityType

The entity type to get navigation properties for.

Returns
System.Collections.Generic.IEnumerable<INavigation> System.Collections.Generic.IEnumerable(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
entityType
IEntityType IEntityType

The entity type to find the foreign keys for.

Returns
System.Collections.Generic.IEnumerable<IForeignKey> System.Collections.Generic.IEnumerable(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
entityType
IEntityType IEntityType

The base entity type.

derivedType
IEntityType IEntityType

The entity type to check if it derives from entityType.

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
entityType
IEntityType IEntityType

The type to compare.

otherEntityType
IEntityType IEntityType

The other entity type to compare with.

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
entityType
IEntityType IEntityType

The type to find the root of.

Returns

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