IMutableEntityType IMutableEntityType Interface

Definition

Represents an entity in an IMutableModel.

This interface is used during model creation and allows the metadata to be modified. Once the model is built, IEntityType represents a ready-only view of the same metadata.

public interface IMutableEntityType : IEntityType, IMutableTypeBase, ITypeBase, IMutableAnnotatable, IAnnotatable
Public Interface IMutableEntityType
    Inherits IEntityType, IMutableTypeBase

Properties

BaseType BaseType

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

IMutableEntityType BaseType { get; set; }
Property BaseType As IMutableEntityType

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.

(Inherited from IEntityType)

Item[String] Item(String)

Gets or sets the value of the annotation with the given name.

(Inherited from IMutableAnnotatable)

Model Model

Gets the model this entity belongs to.

IMutableModel Model { get; }
ReadOnly Property Model As IMutableModel

Name Name

Gets the name of this type.

(Inherited from IEntityType)

Methods

AddAnnotation(String, Object) AddAnnotation(String, Object)

Adds an annotation to this object. Throws if an annotation with the specified name already exists.

(Inherited from IMutableAnnotatable)

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

Adds a new relationship to this entity.

IMutableForeignKey AddForeignKey(IReadOnlyList<IMutableProperty> properties, IMutableKey principalKey, IMutableEntityType principalEntityType)
Function AddForeignKey(properties As IReadOnlyList(Of IMutableProperty), principalKey As IMutableKey, principalEntityType As IMutableEntityType) As IMutableForeignKey
Parameters
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 newly created foreign key.

AddIndex(IReadOnlyList) AddIndex(IReadOnlyList(Of IMutableProperty))

Adds an index to this entity.

IMutableIndex AddIndex(IReadOnlyList<IMutableProperty> properties)
Function AddIndex(properties As IReadOnlyList(Of IMutableProperty)) As IMutableIndex
Parameters
properties
System.Collections.Generic.IReadOnlyList<IMutableProperty> System.Collections.Generic.IReadOnlyList(Of IMutableProperty)

The properties that are to be indexed.

Returns

The newly created index.

AddKey(IReadOnlyList) AddKey(IReadOnlyList(Of IMutableProperty))

Adds a new alternate key to this entity type.

IMutableKey AddKey(IReadOnlyList<IMutableProperty> properties)
Function AddKey(properties As IReadOnlyList(Of IMutableProperty)) As IMutableKey
Parameters
properties
System.Collections.Generic.IReadOnlyList<IMutableProperty> System.Collections.Generic.IReadOnlyList(Of IMutableProperty)

The properties that make up the alternate key.

Returns

The newly created key.

AddProperty(String, Type) AddProperty(String, Type)

Adds a property to this entity.

IMutableProperty AddProperty(string name, Type propertyType)
Function AddProperty(name As String, propertyType As Type) As IMutableProperty
Parameters
name
System.String System.String

The name of the property to add.

propertyType
System.Type System.Type

The type of value the property will hold.

Returns

The newly created property.

FindAnnotation(String) FindAnnotation(String)

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

(Inherited from IMutableAnnotatable)

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.

IMutableForeignKey FindForeignKey(IReadOnlyList<IProperty> properties, IKey principalKey, IEntityType principalEntityType)
Function FindForeignKey(properties As IReadOnlyList(Of IProperty), principalKey As IKey, principalEntityType As IEntityType) As IMutableForeignKey
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.

IMutableIndex FindIndex(IReadOnlyList<IProperty> properties)
Function FindIndex(properties As IReadOnlyList(Of IProperty)) As IMutableIndex
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.

IMutableKey FindKey(IReadOnlyList<IProperty> properties)
Function FindKey(properties As IReadOnlyList(Of IProperty)) As IMutableKey
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.

IMutableKey FindPrimaryKey()
Function FindPrimaryKey As IMutableKey
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(IMutableEntityType, String) to find a navigation property.

IMutableProperty FindProperty(string name)
Function FindProperty(name As String) As IMutableProperty
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 IMutableAnnotatable)

GetForeignKeys() GetForeignKeys()

Gets the foreign keys defined on this entity.

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

The foreign keys defined on this entity.

GetIndexes() GetIndexes()

Gets the indexes defined on this entity.

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

The indexes defined on this entity.

GetKeys() GetKeys()

Gets the primary and alternate keys for this entity.

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

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(IMutableEntityType) to get navigation properties.

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

The properties defined on this entity.

RemoveAnnotation(String) RemoveAnnotation(String)

Removes the given annotation from this object.

(Inherited from IMutableAnnotatable)

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

Removes a relationship from this entity.

IMutableForeignKey RemoveForeignKey(IReadOnlyList<IProperty> properties, IKey principalKey, IEntityType principalEntityType)
Function RemoveForeignKey(properties As IReadOnlyList(Of IProperty), principalKey As IKey, principalEntityType As IEntityType) As IMutableForeignKey
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 that was removed.

RemoveIndex(IReadOnlyList) RemoveIndex(IReadOnlyList(Of IProperty))

Removes an index from this entity.

IMutableIndex RemoveIndex(IReadOnlyList<IProperty> properties)
Function RemoveIndex(properties As IReadOnlyList(Of IProperty)) As IMutableIndex
Parameters
properties
System.Collections.Generic.IReadOnlyList<IProperty> System.Collections.Generic.IReadOnlyList(Of IProperty)

The properties that make up the index.

Returns

The index that was removed.

RemoveKey(IReadOnlyList) RemoveKey(IReadOnlyList(Of IProperty))

Removes a primary or alternate key from this entity.

IMutableKey RemoveKey(IReadOnlyList<IProperty> properties)
Function RemoveKey(properties As IReadOnlyList(Of IProperty)) As IMutableKey
Parameters
properties
System.Collections.Generic.IReadOnlyList<IProperty> System.Collections.Generic.IReadOnlyList(Of IProperty)

The properties that make up the key.

Returns

The key that was removed.

RemoveProperty(String) RemoveProperty(String)

Removes a property from this entity.

IMutableProperty RemoveProperty(string name)
Function RemoveProperty(name As String) As IMutableProperty
Parameters
name
System.String System.String

The name of the property to remove.

Returns

The property that was removed.

SetPrimaryKey(IReadOnlyList) SetPrimaryKey(IReadOnlyList(Of IMutableProperty))

Sets the primary key for this entity.

IMutableKey SetPrimaryKey(IReadOnlyList<IMutableProperty> properties)
Function SetPrimaryKey(properties As IReadOnlyList(Of IMutableProperty)) As IMutableKey
Parameters
properties
System.Collections.Generic.IReadOnlyList<IMutableProperty> System.Collections.Generic.IReadOnlyList(Of IMutableProperty)

The properties that make up the primary key.

Returns

The newly created key.