IMutableEntityType IMutableEntityType Interface

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.

Syntax

Declaration

public interface IMutableEntityType : IEntityType, IMutableTypeBase, ITypeBase, IMutableAnnotatable, IAnnotatablePublic Interface IMutableEntityType
    Inherits IEntityType, IMutableTypeBase

Inherited Members

Name,
Name,
ClrType,
ClrType,
Item[String],
Item(String),
GetAnnotations(),
GetAnnotations(),
AddAnnotation(String, Object),
AddAnnotation(String, Object),
FindAnnotation(String),
FindAnnotation(String),
RemoveAnnotation(String)
RemoveAnnotation(String)

Properties summary

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

Gets the model this entity belongs to.

Methods summary

Adds a new relationship to this entity.

Adds an index to this entity.

Adds a new alternate key to this entity type.

Adds a property to this entity.

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

Removes a relationship from this entity.

Removes an index from this entity.

Removes a primary or alternate key from this entity.

Removes a property from this entity.

Sets the primary key for this entity.

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

    Property Value

  • Model
    Model

    Gets the model this entity belongs to.

    IMutableModel Model { get; }ReadOnly Property Model As IMutableModel

    Property Value

Methods

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

      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

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

      The properties that are to be indexed.

    Returns

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

      The properties that make up the alternate key.

    Returns

  • 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

  • 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.

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

    IMutableIndex FindIndex(IReadOnlyList<IProperty> properties)Function FindIndex(properties As IReadOnlyList(Of IProperty)) As IMutableIndex

    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.

    IMutableKey FindKey(IReadOnlyList<IProperty> properties)Function FindKey(properties As IReadOnlyList(Of IProperty)) As IMutableKey

    Parameters

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

      The properties that make up the key.

    Returns

  • 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

  • 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

  • GetForeignKeys()
    GetForeignKeys()

    Gets the foreign keys defined on this entity.

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

    Returns

  • GetIndexes()
    GetIndexes()

    Gets the indexes defined on this entity.

    IEnumerable<IMutableIndex> GetIndexes()Function GetIndexes As IEnumerable(Of IMutableIndex)

    Returns

    • System.Collections.Generic.IEnumerable<T><IMutableIndex>
      System.Collections.Generic.IEnumerable<T>(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<T><IMutableKey>
      System.Collections.Generic.IEnumerable<T>(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<T><IMutableProperty>
      System.Collections.Generic.IEnumerable<T>(Of IMutableProperty)

      The properties defined on this entity.

  • RemoveForeignKey(IReadOnlyList<IProperty>, 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<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

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

      The properties that make up the index.

    Returns

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

      The properties that make up the key.

    Returns

  • 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

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

      The properties that make up the primary key.

    Returns

Details

Assembly

Microsoft.EntityFrameworkCore.dll