MutableEntityTypeExtensions MutableEntityTypeExtensions Class

Definition

Extension methods for IMutableEntityType.

public static class MutableEntityTypeExtensions
Public Module MutableEntityTypeExtensions
Inheritance
System.ObjectSystem.Object
MutableEntityTypeExtensionsMutableEntityTypeExtensions

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

AddForeignKey(IMutableEntityType, IMutableProperty, IMutableKey, IMutableEntityType) AddForeignKey(IMutableEntityType, IMutableProperty, IMutableKey, IMutableEntityType)

Adds a new relationship to this entity.

public static IMutableForeignKey AddForeignKey(this IMutableEntityType entityType, IMutableProperty property, IMutableKey principalKey, IMutableEntityType principalEntityType)
<ExtensionAttribute>
Public Shared Function AddForeignKey(entityType As IMutableEntityType, property As IMutableProperty, principalKey As IMutableKey, principalEntityType As IMutableEntityType) As IMutableForeignKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to add the foreign key to.

property
IMutableProperty IMutableProperty

The property that the foreign key is defined on.

principalKey
IMutableKey IMutableKey

The primary or alternate key that is referenced.

principalEntityType
IMutableEntityType IMutableEntityType

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 newly created foreign key.

AddIndex(IMutableEntityType, IMutableProperty) AddIndex(IMutableEntityType, IMutableProperty)

Adds an index to this entity.

public static IMutableIndex AddIndex(this IMutableEntityType entityType, IMutableProperty property)
<ExtensionAttribute>
Public Shared Function AddIndex(entityType As IMutableEntityType, property As IMutableProperty) As IMutableIndex
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to add the index to.

property
IMutableProperty IMutableProperty

The property to be indexed.

Returns

The newly created index.

AddKey(IMutableEntityType, IMutableProperty) AddKey(IMutableEntityType, IMutableProperty)

Adds a new alternate key to this entity type.

public static IMutableKey AddKey(this IMutableEntityType entityType, IMutableProperty property)
<ExtensionAttribute>
Public Shared Function AddKey(entityType As IMutableEntityType, property As IMutableProperty) As IMutableKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to add the alternate key to.

property
IMutableProperty IMutableProperty

The property to use as an alternate key.

Returns

The newly created key.

AddProperty(IMutableEntityType, PropertyInfo) AddProperty(IMutableEntityType, PropertyInfo)

Adds a property to this entity.

public static IMutableProperty AddProperty(this IMutableEntityType entityType, PropertyInfo propertyInfo)
<ExtensionAttribute>
Public Shared Function AddProperty(entityType As IMutableEntityType, propertyInfo As PropertyInfo) As IMutableProperty
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to add the property to.

propertyInfo
System.Reflection.PropertyInfo System.Reflection.PropertyInfo

The corresponding property in the entity class.

Returns

The newly created property.

FindForeignKey(IMutableEntityType, IProperty, IKey, IEntityType) FindForeignKey(IMutableEntityType, 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 IMutableForeignKey FindForeignKey(this IMutableEntityType entityType, IProperty property, IKey principalKey, IEntityType principalEntityType)
<ExtensionAttribute>
Public Shared Function FindForeignKey(entityType As IMutableEntityType, property As IProperty, principalKey As IKey, principalEntityType As IEntityType) As IMutableForeignKey
Parameters
entityType
IMutableEntityType IMutableEntityType

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(IMutableEntityType, IProperty) FindForeignKeys(IMutableEntityType, 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<IMutableForeignKey> FindForeignKeys(this IMutableEntityType entityType, IProperty property)
<ExtensionAttribute>
Public Shared Function FindForeignKeys(entityType As IMutableEntityType, property As IProperty) As IEnumerable(Of IMutableForeignKey)
Parameters
entityType
IMutableEntityType IMutableEntityType

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<IMutableForeignKey> System.Collections.Generic.IEnumerable(Of IMutableForeignKey)

The foreign keys.

FindForeignKeys(IMutableEntityType, IReadOnlyList) FindForeignKeys(IMutableEntityType, 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<IMutableForeignKey> FindForeignKeys(this IMutableEntityType entityType, IReadOnlyList<IProperty> properties)
<ExtensionAttribute>
Public Shared Function FindForeignKeys(entityType As IMutableEntityType, properties As IReadOnlyList(Of IProperty)) As IEnumerable(Of IMutableForeignKey)
Parameters
entityType
IMutableEntityType IMutableEntityType

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<IMutableForeignKey> System.Collections.Generic.IEnumerable(Of IMutableForeignKey)

The foreign keys.

FindIndex(IMutableEntityType, IProperty) FindIndex(IMutableEntityType, IProperty)

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

public static IMutableIndex FindIndex(this IMutableEntityType entityType, IProperty property)
<ExtensionAttribute>
Public Shared Function FindIndex(entityType As IMutableEntityType, property As IProperty) As IMutableIndex
Parameters
entityType
IMutableEntityType IMutableEntityType

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(IMutableEntityType, IProperty) FindKey(IMutableEntityType, 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 IMutableKey FindKey(this IMutableEntityType entityType, IProperty property)
<ExtensionAttribute>
Public Shared Function FindKey(entityType As IMutableEntityType, property As IProperty) As IMutableKey
Parameters
entityType
IMutableEntityType IMutableEntityType

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(IMutableEntityType, PropertyInfo) FindNavigation(IMutableEntityType, PropertyInfo)

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

public static IMutableNavigation FindNavigation(this IMutableEntityType entityType, PropertyInfo propertyInfo)
<ExtensionAttribute>
Public Shared Function FindNavigation(entityType As IMutableEntityType, propertyInfo As PropertyInfo) As IMutableNavigation
Parameters
entityType
IMutableEntityType IMutableEntityType

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(IMutableEntityType, String) FindNavigation(IMutableEntityType, String)

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

public static IMutableNavigation FindNavigation(this IMutableEntityType entityType, string name)
<ExtensionAttribute>
Public Shared Function FindNavigation(entityType As IMutableEntityType, name As String) As IMutableNavigation
Parameters
entityType
IMutableEntityType IMutableEntityType

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(IMutableEntityType, PropertyInfo) FindProperty(IMutableEntityType, 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(IMutableEntityType, PropertyInfo) to find a navigation property.

public static IMutableProperty FindProperty(this IMutableEntityType entityType, PropertyInfo propertyInfo)
<ExtensionAttribute>
Public Shared Function FindProperty(entityType As IMutableEntityType, propertyInfo As PropertyInfo) As IMutableProperty
Parameters
entityType
IMutableEntityType IMutableEntityType

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.

GetDerivedTypes(IMutableEntityType) GetDerivedTypes(IMutableEntityType)

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

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

The base type to find types that derive from.

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

The derived types.

GetNavigations(IMutableEntityType) GetNavigations(IMutableEntityType)

Gets all navigation properties on the given entity type.

public static IEnumerable<IMutableNavigation> GetNavigations(this IMutableEntityType entityType)
<ExtensionAttribute>
Public Shared Function GetNavigations(entityType As IMutableEntityType) As IEnumerable(Of IMutableNavigation)
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get navigation properties for.

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

All navigation properties on the given entity type.

GetOrAddForeignKey(IMutableEntityType, IMutableProperty, IMutableKey, IMutableEntityType) GetOrAddForeignKey(IMutableEntityType, IMutableProperty, IMutableKey, IMutableEntityType)

Gets an existing relationship, or creates a new one if one is not already defined.

public static IMutableForeignKey GetOrAddForeignKey(this IMutableEntityType entityType, IMutableProperty property, IMutableKey principalKey, IMutableEntityType principalEntityType)
<ExtensionAttribute>
Public Shared Function GetOrAddForeignKey(entityType As IMutableEntityType, property As IMutableProperty, principalKey As IMutableKey, principalEntityType As IMutableEntityType) As IMutableForeignKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or add the foreign key to.

property
IMutableProperty IMutableProperty

The property that the foreign key is defined on.

principalKey
IMutableKey IMutableKey

The primary or alternate key that is referenced.

principalEntityType
IMutableEntityType IMutableEntityType

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 existing or newly created foreign key.

GetOrAddForeignKey(IMutableEntityType, IReadOnlyList, IMutableKey, IMutableEntityType) GetOrAddForeignKey(IMutableEntityType, IReadOnlyList(Of IMutableProperty), IMutableKey, IMutableEntityType)

Gets an existing relationship, or creates a new one if one is not already defined.

public static IMutableForeignKey GetOrAddForeignKey(this IMutableEntityType entityType, IReadOnlyList<IMutableProperty> properties, IMutableKey principalKey, IMutableEntityType principalEntityType)
<ExtensionAttribute>
Public Shared Function GetOrAddForeignKey(entityType As IMutableEntityType, properties As IReadOnlyList(Of IMutableProperty), principalKey As IMutableKey, principalEntityType As IMutableEntityType) As IMutableForeignKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or add the foreign key to.

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

The properties that the foreign key is defined on.

principalKey
IMutableKey IMutableKey

The primary or alternate key that is referenced.

principalEntityType
IMutableEntityType IMutableEntityType

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 existing or newly created foreign key.

GetOrAddIndex(IMutableEntityType, IMutableProperty) GetOrAddIndex(IMutableEntityType, IMutableProperty)

Gets the index defined on the given property or creates a new one if one is not already defined.

public static IMutableIndex GetOrAddIndex(this IMutableEntityType entityType, IMutableProperty property)
<ExtensionAttribute>
Public Shared Function GetOrAddIndex(entityType As IMutableEntityType, property As IMutableProperty) As IMutableIndex
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or add the index to.

property
IMutableProperty IMutableProperty

The property to be indexed.

Returns

The existing or newly created index.

GetOrAddIndex(IMutableEntityType, IReadOnlyList) GetOrAddIndex(IMutableEntityType, IReadOnlyList(Of IMutableProperty))

Gets the index defined on the given property or creates a new one if one is not already defined.

public static IMutableIndex GetOrAddIndex(this IMutableEntityType entityType, IReadOnlyList<IMutableProperty> properties)
<ExtensionAttribute>
Public Shared Function GetOrAddIndex(entityType As IMutableEntityType, properties As IReadOnlyList(Of IMutableProperty)) As IMutableIndex
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or add the index to.

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

The properties to be indexed.

Returns

The existing or newly created index.

GetOrAddKey(IMutableEntityType, IMutableProperty) GetOrAddKey(IMutableEntityType, IMutableProperty)

Gets the existing alternate key defined on a property, or creates a new one if one is not already defined.

public static IMutableKey GetOrAddKey(this IMutableEntityType entityType, IMutableProperty property)
<ExtensionAttribute>
Public Shared Function GetOrAddKey(entityType As IMutableEntityType, property As IMutableProperty) As IMutableKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or create the alternate key on.

property
IMutableProperty IMutableProperty

The property that is used as the alternate key.

Returns

The existing or newly created alternate key.

GetOrAddKey(IMutableEntityType, IReadOnlyList) GetOrAddKey(IMutableEntityType, IReadOnlyList(Of IMutableProperty))

Gets the existing alternate key defined on a set of properties, or creates a new one if one is not already defined.

public static IMutableKey GetOrAddKey(this IMutableEntityType entityType, IReadOnlyList<IMutableProperty> properties)
<ExtensionAttribute>
Public Shared Function GetOrAddKey(entityType As IMutableEntityType, properties As IReadOnlyList(Of IMutableProperty)) As IMutableKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or create the alternate key on.

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

The properties that are used as the alternate key.

Returns

The existing or newly created alternate key.

GetOrAddProperty(IMutableEntityType, PropertyInfo) GetOrAddProperty(IMutableEntityType, PropertyInfo)

Gets the property with the given name, or creates a new one if one is not already defined.

public static IMutableProperty GetOrAddProperty(this IMutableEntityType entityType, PropertyInfo propertyInfo)
<ExtensionAttribute>
Public Shared Function GetOrAddProperty(entityType As IMutableEntityType, propertyInfo As PropertyInfo) As IMutableProperty
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or add the property to.

propertyInfo
System.Reflection.PropertyInfo System.Reflection.PropertyInfo

The corresponding property in the entity class.

Returns

The existing or newly created property.

Remarks

The returned property might not have the specified type and shadowness.

GetOrAddProperty(IMutableEntityType, String, Type) GetOrAddProperty(IMutableEntityType, String, Type)

Gets the property with the given name, or creates a new one if one is not already defined.

public static IMutableProperty GetOrAddProperty(this IMutableEntityType entityType, string name, Type propertyType)
<ExtensionAttribute>
Public Shared Function GetOrAddProperty(entityType As IMutableEntityType, name As String, propertyType As Type) As IMutableProperty
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or add the property to.

name
System.String System.String

The name of the property.

propertyType
System.Type System.Type

The type of value the property will hold.

Returns

The existing or newly created property.

Remarks

The returned property might not have the specified type and shadowness.

GetOrSetPrimaryKey(IMutableEntityType, IMutableProperty) GetOrSetPrimaryKey(IMutableEntityType, IMutableProperty)

Gets the existing primary key of an entity, or sets it if one is not defined.

public static IMutableKey GetOrSetPrimaryKey(this IMutableEntityType entityType, IMutableProperty property)
<ExtensionAttribute>
Public Shared Function GetOrSetPrimaryKey(entityType As IMutableEntityType, property As IMutableProperty) As IMutableKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or set the key on.

property
IMutableProperty IMutableProperty

The property to set as the primary key if one is not already defined.

Returns

The existing or newly created key.

GetOrSetPrimaryKey(IMutableEntityType, IReadOnlyList) GetOrSetPrimaryKey(IMutableEntityType, IReadOnlyList(Of IMutableProperty))

Gets the existing primary key of an entity, or sets it if one is not defined.

public static IMutableKey GetOrSetPrimaryKey(this IMutableEntityType entityType, IReadOnlyList<IMutableProperty> properties)
<ExtensionAttribute>
Public Shared Function GetOrSetPrimaryKey(entityType As IMutableEntityType, properties As IReadOnlyList(Of IMutableProperty)) As IMutableKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to get or set the key on.

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

The properties to set as the primary key if one is not already defined.

Returns

The existing or newly created key.

GetReferencingForeignKeys(IMutableEntityType) GetReferencingForeignKeys(IMutableEntityType)

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<IMutableForeignKey> GetReferencingForeignKeys(this IMutableEntityType entityType)
<ExtensionAttribute>
Public Shared Function GetReferencingForeignKeys(entityType As IMutableEntityType) As IEnumerable(Of IMutableForeignKey)
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to find the foreign keys for.

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

The foreign keys that reference the given entity type.

RootType(IMutableEntityType) RootType(IMutableEntityType)

Gets the root base type for a given entity type.

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

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.

SetPrimaryKey(IMutableEntityType, IMutableProperty) SetPrimaryKey(IMutableEntityType, IMutableProperty)

Sets the primary key for this entity.

public static IMutableKey SetPrimaryKey(this IMutableEntityType entityType, IMutableProperty property)
<ExtensionAttribute>
Public Shared Function SetPrimaryKey(entityType As IMutableEntityType, property As IMutableProperty) As IMutableKey
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type to set the key on.

property
IMutableProperty IMutableProperty

The primary key property.

Returns

The newly created key.

SetPropertyAccessMode(IMutableEntityType, Nullable) SetPropertyAccessMode(IMutableEntityType, Nullable(Of PropertyAccessMode))

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

Note that individual properties can override this access mode. The value set here will be used for any property for which no override has been specified.

public static void SetPropertyAccessMode(this IMutableEntityType entityType, PropertyAccessMode? propertyAccessMode)
<ExtensionAttribute>
Public Shared Sub SetPropertyAccessMode(entityType As IMutableEntityType, propertyAccessMode As PropertyAccessMode?)
Parameters
entityType
IMutableEntityType IMutableEntityType

The entity type for which to set the access mode.

propertyAccessMode
System.Nullable<PropertyAccessMode> System.Nullable(Of PropertyAccessMode)

The PropertyAccessMode, or null to clear the mode set.