IMutableModel Interface

Definition

Metadata about the shape of entities, the relationships between them, and how they map to the database. A model is typically created by overriding the OnModelCreating(ModelBuilder) method on a derived DbContext.

public interface IMutableModel : Microsoft.EntityFrameworkCore.Metadata.IModel, Microsoft.EntityFrameworkCore.Metadata.IMutableAnnotatable
public interface IMutableModel : Microsoft.EntityFrameworkCore.Metadata.IMutableAnnotatable, Microsoft.EntityFrameworkCore.Metadata.IReadOnlyModel
type IMutableModel = interface
    interface IModel
    interface IAnnotatable
    interface IMutableAnnotatable
type IMutableModel = interface
    interface IReadOnlyModel
    interface IReadOnlyAnnotatable
    interface IMutableAnnotatable
Public Interface IMutableModel
Implements IModel, IMutableAnnotatable
Public Interface IMutableModel
Implements IMutableAnnotatable, IReadOnlyModel
Implements

Remarks

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

See Modeling entity types and relationships for more information and examples.

Properties

Item[String]

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

(Inherited from IReadOnlyAnnotatable)
ModelDependencies

The runtime service dependencies.

(Inherited from IModel)
ModelId

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

(Inherited from IReadOnlyModel)

Methods

AddAnnotation(String, Object)

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

(Inherited from IMutableAnnotatable)
AddAnnotations(IEnumerable<IAnnotation>)

Adds annotations to an object.

(Inherited from IMutableAnnotatable)
AddEntityType(String)

Adds an entity type of default type to the model.

AddEntityType(String, String, IMutableEntityType)

Adds an owned entity type with a defining navigation to the model.

AddEntityType(String, Type)

Adds a shared type entity type to the model.

AddEntityType(Type)

Adds an entity type to the model.

AddEntityType(Type, String, IMutableEntityType)

Adds an owned entity type with a defining navigation to the model.

AddIgnored(String)

Marks the given entity type name as ignored, preventing conventions from adding a matching entity type to the model.

AddIgnored(Type)

Marks the given entity type as ignored, preventing conventions from adding a matching entity type to the model.

AddOwned(Type)

Marks the given entity type as owned, indicating that when discovered matching entity types should be configured as owned.

AddOwnedEntityType(String)

Adds an owned entity type of default type to the model.

AddOwnedEntityType(String, Type)

Adds an owned shared type entity type to the model.

AddOwnedEntityType(Type)

Adds an owned entity type to the model.

AddQueryType(Type)

Adds a query type to the model.

AddRuntimeAnnotation(String, Object)

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

(Inherited from IAnnotatable)
AddShared(Type)

Marks the given entity type as shared, indicating that when discovered matching entity types should be configured as shared type entity type.

AnnotationsToDebugString(Int32)

Gets the debug string for all annotations declared on the object.

(Inherited from IReadOnlyAnnotatable)
DelayConventions()

Prevents conventions from being executed immediately when a metadata aspect is modified. All the delayed conventions will be executed after the returned object is disposed.

FinalizeModel()

Forces post-processing on the model such that it is ready for use by the runtime. This post- processing happens automatically when using OnModelCreating(ModelBuilder); this method allows it to be run explicitly in cases where the automatic execution is not possible.

FindAnnotation(String)

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

(Inherited from IReadOnlyAnnotatable)
FindEntityType(String)

Gets the entity with the given name. Returns null if no entity type with the given name is found or the given CLR type is being used by shared type entity type or the entity type has a defining navigation.

FindEntityType(String, String, IEntityType)

Gets the entity type for the given name, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

(Inherited from IModel)
FindEntityType(String, String, IMutableEntityType)

Gets the entity type for the given name, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

FindEntityType(String, String, IReadOnlyEntityType)

Gets the entity type for the given base name, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

(Inherited from IReadOnlyModel)
FindEntityType(Type)

Gets the entity that maps the given entity class. Returns null if no entity type with the given CLR type is found or the given CLR type is being used by shared type entity type or the entity type has a defining navigation.

FindEntityType(Type, String, IEntityType)

Gets the entity type for the given name, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

(Inherited from IModel)
FindEntityType(Type, String, IMutableEntityType)

Gets the entity type for the given name, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

FindEntityType(Type, String, IReadOnlyEntityType)

Gets the entity type for the given type, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

(Inherited from IReadOnlyModel)
FindEntityTypes(Type)

Gets the entity types matching the given type.

FindLeastDerivedEntityTypes(Type, Func<IReadOnlyEntityType,Boolean>)

Returns the entity types corresponding to the least derived types from the given one.

FindRuntimeAnnotation(String)

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

(Inherited from IAnnotatable)
FindRuntimeAnnotationValue(String)

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

(Inherited from IAnnotatable)
FindRuntimeEntityType(Type)

Gets the entity that maps the given entity class, where the class may be a proxy derived from the actual entity type. Returns null if no entity type with the given CLR type is found or the given CLR type is being used by shared type entity type or the entity type has a defining navigation.

(Inherited from IModel)
FindTypeMappingConfiguration(Type)

Finds the pre-convention configuration for a given scalar Type.

(Inherited from IModel)
GetAnnotation(String)

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

(Inherited from IReadOnlyAnnotatable)
GetAnnotations()

Gets all annotations on the current object.

(Inherited from IReadOnlyAnnotatable)
GetChangeTrackingStrategy()

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

(Inherited from IReadOnlyModel)
GetEntityTypes()

Gets all entity types defined in the model.

GetModelDependencies()

Gets the runtime service dependencies.

(Inherited from IModel)
GetOrAddRuntimeAnnotationValue<TValue,TArg>(String, Func<TArg,TValue>, TArg)

Gets the value of the runtime annotation with the given name, adding it if one does not exist.

(Inherited from IAnnotatable)
GetProductVersion()

Gets the EF Core assembly version used to build this model.

(Inherited from IReadOnlyModel)
GetPropertyAccessMode()

Gets the PropertyAccessMode being used for properties of entity types in this model.

(Inherited from IReadOnlyModel)
GetRuntimeAnnotations()

Gets all the runtime annotations on the current object.

(Inherited from IAnnotatable)
GetTypeMappingConfigurations()

Gets all the pre-convention configurations.

(Inherited from IModel)
IsIgnored(String)

Indicates whether the given entity type name is ignored.

IsIgnored(Type)

Indicates whether the given entity type name is ignored.

IsIndexerMethod(MethodInfo)

Gets a value indicating whether the given MethodInfo represents an indexer access.

(Inherited from IModel)
IsOwned(Type)

Returns a value indicating whether the entity types using the given type should be configured as owned types when discovered by conventions.

IsShared(Type)

Gets a value indicating whether the CLR type is used by shared type entities in the model.

(Inherited from IReadOnlyModel)
RemoveAnnotation(String)

Removes the given annotation from this object.

(Inherited from IMutableAnnotatable)
RemoveEntityType(IMutableEntityType)

Removes an entity type from the model.

RemoveEntityType(String)

Removes an entity type without a defining navigation from the model.

RemoveEntityType(String, String, IMutableEntityType)

Removes an entity type with the given type, defining navigation name and the defining entity type

RemoveEntityType(Type)

Removes an entity type from the model.

RemoveEntityType(Type, String, IMutableEntityType)

Removes an entity type with the given type, defining navigation name and the defining entity type

RemoveIgnored(String)

Removes the ignored entity type name.

RemoveIgnored(Type)

Removes the ignored entity type.

RemoveOwned(Type)

Removes the given owned type, indicating that when discovered matching entity types should not be configured as owned.

RemoveRuntimeAnnotation(String)

Removes the given runtime annotation from this object.

(Inherited from IAnnotatable)
RemoveShared(Type)

Marks the given type as not shared, indicating that when discovered matching entity types should not be configured as shared type entity types.

SetAnnotation(String, Object)

Sets the annotation stored under the given key. Overwrites the existing annotation if an annotation with the specified name already exists.

(Inherited from IMutableAnnotatable)
SetChangeTrackingStrategy(Nullable<ChangeTrackingStrategy>)

Sets the default change tracking strategy to use for entities in the model. This strategy indicates how the context detects changes to properties for an instance of an entity type.

SetOrRemoveAnnotation(String, Object)

Sets the annotation stored under the given name. Overwrites the existing annotation if an annotation with the specified name already exists. Removes the existing annotation if null is supplied.

(Inherited from IMutableAnnotatable)
SetPropertyAccessMode(Nullable<PropertyAccessMode>)

Sets the PropertyAccessMode to use for properties of all entity types in this model.

SetRuntimeAnnotation(String, Object)

Sets the runtime annotation stored under the given key. Overwrites the existing annotation if an annotation with the specified name already exists.

(Inherited from IAnnotatable)
ToDebugString(MetadataDebugStringOptions, Int32)

Creates a human-readable representation of the given metadata.

Warning: Do not rely on the format of the returned string. It is designed for debugging only and may change arbitrarily between releases.

(Inherited from IReadOnlyModel)

Extension Methods

GetDefaultContainer(IModel)

Returns the default container name.

GetDefaultContainer(IReadOnlyModel)

Returns the default container name.

GetThroughput(IReadOnlyModel)

Returns the provisioned throughput at database scope.

SetDefaultContainer(IMutableModel, String)

Sets the default container name.

SetThroughput(IMutableModel, Nullable<Int32>, Nullable<Boolean>)

Sets the provisioned throughput at database scope.

AnnotationsToDebugString(IAnnotatable, Int32)

Gets the debug string for all annotations declared on the object.

GetAnnotation(IAnnotatable, String)

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

Scaffolding(IModel)
FindEntityType(IModel, Type)
Obsolete.

Gets the entity that maps the given entity class. Returns null if no entity type with the given CLR type is found or the given CLR type is being used by shared type entity type or the entity type has a defining navigation.

FindEntityType(IModel, Type, String, IEntityType)

Gets the entity type for the given type, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

FindRuntimeEntityType(IModel, Type)

Gets the entity that maps the given entity class, where the class may be a proxy derived from the actual entity type. Returns null if no entity type with the given CLR type is found or the given CLR type is being used by shared type entity type or the entity type has a defining navigation.

GetChangeTrackingStrategy(IModel)

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

GetEntityTypes(IModel, String)
Obsolete.

Gets the entity types matching the given name.

GetEntityTypes(IModel, Type)
Obsolete.

Gets the entity types matching the given type.

GetProductVersion(IModel)

Gets the EF Core assembly version used to build this model

GetPropertyAccessMode(IModel)

Gets the PropertyAccessMode being used for properties of entity types in this model.

Note that individual entity types can override this access mode, and individual properties of entity types can override the access mode set on the entity type. The value returned here will be used for any property for which no override has been specified.

HasEntityTypeWithDefiningNavigation(IModel, String)
Obsolete.

Gets a value indicating whether the model contains a corresponding entity type with a defining navigation.

HasEntityTypeWithDefiningNavigation(IModel, Type)
Obsolete.

Gets a value indicating whether the model contains a corresponding entity type with a defining navigation.

IsIndexerMethod(IModel, MethodInfo)

Gets a value indicating whether the given MethodInfo reprensent an indexer access.

IsShared(IModel, Type)

Gets whether the CLR type is used by shared type entities in the model.

ToDebugString(IModel, MetadataDebugStringOptions, Int32)

Creates a human-readable representation of the given metadata.

Warning: Do not rely on the format of the returned string. It is designed for debugging only and may change arbitrarily between releases.

AddAnnotations(IMutableAnnotatable, IEnumerable<IAnnotation>)

Adds annotations to an object.

GetAnnotation(IMutableAnnotatable, String)

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

GetOrAddAnnotation(IMutableAnnotatable, String, String)

Gets the existing annotation with a given key, or adds a new annotation if one does not exist.

SetOrRemoveAnnotation(IMutableAnnotatable, String, Object)

Sets the annotation stored under the given name. Overwrites the existing annotation if an annotation with the specified name already exists. Removes the existing annotation if null is supplied.

AddIgnored(IMutableModel, Type)

Marks the given entity type as ignored, preventing conventions from adding a matching entity type to the model.

AddOwned(IMutableModel, Type)

Marks the given entity type as owned, indicating that when discovered matching entity types should be configured as owned.

AddShared(IMutableModel, Type)

Marks the given entity type as shared, indicating that when discovered matching entity types should be configured as shared type entity type.

FinalizeModel(IMutableModel)

Forces post-processing on the model such that it is ready for use by the runtime. This post processing happens automatically when using OnModelCreating(ModelBuilder); this method allows it to be run explicitly in cases where the automatic execution is not possible.

FindEntityType(IMutableModel, Type)

Gets the entity that maps the given entity class. Returns null if no entity type with the given CLR type is found or the given CLR type is being used by shared type entity type or the entity type has a defining navigation.

FindEntityType(IMutableModel, Type, String, IMutableEntityType)

Gets the entity type for the given name, defining navigation name and the defining entity type. Returns null if no matching entity type is found.

FindLeastDerivedEntityTypes(IMutableModel, Type, Func<IMutableEntityType,Boolean>)

Returns the entity types corresponding to the least derived types from the given.

GetEntityTypes(IMutableModel, String)
Obsolete.

Gets the entity types matching the given name.

GetEntityTypes(IMutableModel, Type)
Obsolete.

Gets the entity types matching the given type.

GetOrAddEntityType(IMutableModel, String)

Gets the entity type with the given name or adds a new entity type if none is found.

GetOrAddEntityType(IMutableModel, Type)

Gets the entity type with the given CLR class or adds a new entity type if none is found.

IsIgnored(IMutableModel, Type)

Indicates whether the given entity type name is ignored.

IsOwned(IMutableModel, Type)

Returns a value indicating whether the entity types using the given type should be configured as owned types when discovered by conventions.

RemoveEntityType(IMutableModel, IMutableEntityType)

Removes an entity type from the model.

RemoveEntityType(IMutableModel, String)

Removes an entity type without a defining navigation from the model.

RemoveEntityType(IMutableModel, String, String, IMutableEntityType)

Removes an entity type with a defining navigation from the model.

RemoveEntityType(IMutableModel, Type)

Removes an entity type from the model.

RemoveEntityType(IMutableModel, Type, String, IMutableEntityType)

Removes an entity type with a defining navigation from the model.

RemoveIgnored(IMutableModel, Type)

Removes the ignored entity type.

RemoveOwned(IMutableModel, Type)

Removes the given owned type, indicating that when discovered matching entity types should not be configured as owned.

SetChangeTrackingStrategy(IMutableModel, ChangeTrackingStrategy)

Sets the default change tracking strategy to use for entities in the model. This strategy indicates how the context detects changes to properties for an instance of an entity type.

SetChangeTrackingStrategy(IMutableModel, Nullable<ChangeTrackingStrategy>)

Sets the default change tracking strategy to use for entities in the model. This strategy indicates how the context detects changes to properties for an instance of an entity type.

SetPropertyAccessMode(IMutableModel, Nullable<PropertyAccessMode>)

Sets the PropertyAccessMode to use for properties of all entity types in this model.

Note that individual entity types can override this access mode, and individual properties of entity types can override the access mode set on the entity type. The value set here will be used for any property for which no override has been specified.

SetPropertyAccessMode(IMutableModel, Nullable<PropertyAccessMode>)

Sets the PropertyAccessMode to use for properties of all entity types in this model.

Note that individual entity types can override this access mode, and individual properties of entity types can override the access mode set on the entity type. The value set here will be used for any property for which no override has been specified.

Relational(IModel)

Gets the relational database specific metadata for a model.

Relational(IMutableModel)

Gets the relational database specific metadata for a model.

AddDbFunction(IMutableModel, MethodInfo)

Creates an IMutableDbFunction mapped to the given method.

AddDbFunction(IMutableModel, String, Type)

Creates a function.

AddSequence(IMutableModel, String, String)

Either returns the existing IMutableSequence with the given name in the given schema or creates a new sequence with the given name and schema.

FindDbFunction(IModel, MethodInfo)

Finds a function that is mapped to the method represented by the given MethodInfo.

FindDbFunction(IModel, String)

Finds a function that is mapped to the method represented by the given name.

FindDbFunction(IMutableModel, MethodInfo)

Finds a function that is mapped to the method represented by the given MethodInfo.

FindDbFunction(IMutableModel, String)

Finds a function that is mapped to the method represented by the given name.

FindDbFunction(IReadOnlyModel, MethodInfo)

Finds a function that is mapped to the method represented by the given MethodInfo.

FindDbFunction(IReadOnlyModel, String)

Finds a function that is mapped to the method represented by the given name.

FindSequence(IModel, String, String)

Finds a sequence with the given name.

FindSequence(IMutableModel, String, String)

Finds a sequence with the given name.

FindSequence(IReadOnlyModel, String, String)

Finds a sequence with the given name.

GetCollation(IModel)

Returns the database collation.

GetCollation(IReadOnlyModel)

Returns the database collation.

GetDbFunctions(IModel)

Returns all functions contained in the model.

GetDbFunctions(IMutableModel)

Returns all functions contained in the model.

GetDbFunctions(IReadOnlyModel)

Returns all functions contained in the model.

GetDefaultSchema(IModel)

Returns the default schema to use for the model, or null if none has been set.

GetDefaultSchema(IReadOnlyModel)

Returns the default schema to use for the model, or null if none has been set.

GetMaxIdentifierLength(IModel)

Returns the maximum length allowed for store identifiers.

GetMaxIdentifierLength(IReadOnlyModel)

Returns the maximum length allowed for store identifiers.

GetRelationalModel(IModel)

Returns the database model.

GetSequences(IModel)

Returns all sequences contained in the model.

GetSequences(IMutableModel)

Returns all sequences contained in the model.

GetSequences(IReadOnlyModel)

Returns all sequences contained in the model.

RemoveDbFunction(IMutableModel, MethodInfo)

Removes the function that is mapped to the method represented by the given MethodInfo.

RemoveDbFunction(IMutableModel, String)

Removes the function that is mapped to the method represented by the given MethodInfo.

RemoveSequence(IMutableModel, String, String)

Removes the IMutableSequence with the given name.

SetCollation(IMutableModel, String)

Sets the database collation.

SetDefaultSchema(IMutableModel, String)

Sets the default schema.

SetMaxIdentifierLength(IMutableModel, Nullable<Int32>)

Sets the maximum length allowed for store identifiers.

Sqlite(IModel)

Gets the SQLite specific metadata for a model.

Sqlite(IMutableModel)

Gets the SQLite specific metadata for a model.

SqlServer(IModel)

Gets the SQL Server specific metadata for a model.

SqlServer(IMutableModel)

Gets the SQL Server specific metadata for a model.

GetDatabaseMaxSize(IModel)

Returns the maximum size of the database.

GetDatabaseMaxSize(IReadOnlyModel)

Returns the maximum size of the database.

GetHiLoSequenceName(IModel)

Returns the name to use for the default hi-lo sequence.

GetHiLoSequenceName(IReadOnlyModel)

Returns the name to use for the default hi-lo sequence.

GetHiLoSequenceSchema(IModel)

Returns the schema to use for the default hi-lo sequence. UseHiLo(PropertyBuilder, String, String)

GetHiLoSequenceSchema(IReadOnlyModel)

Returns the schema to use for the default hi-lo sequence. UseHiLo(PropertyBuilder, String, String)

GetIdentityIncrement(IModel)

Returns the default identity increment.

GetIdentityIncrement(IReadOnlyModel)

Returns the default identity increment.

GetIdentitySeed(IModel)

Returns the default identity seed.

GetIdentitySeed(IReadOnlyModel)

Returns the default identity seed.

GetPerformanceLevelSql(IModel)

Returns the performance level of the database.

GetPerformanceLevelSql(IReadOnlyModel)

Returns the performance level of the database.

GetSequenceNameSuffix(IReadOnlyModel)

Returns the suffix to append to the name of automatically created sequences.

GetSequenceSchema(IReadOnlyModel)

Returns the schema to use for the default value generation sequence. UseSequence(PropertyBuilder, String, String)

GetServiceTierSql(IModel)

Returns the service tier of the database.

GetServiceTierSql(IReadOnlyModel)

Returns the service tier of the database.

GetValueGenerationStrategy(IModel)

Returns the SqlServerValueGenerationStrategy to use for properties of keys in the model, unless the property has a strategy explicitly set.

GetValueGenerationStrategy(IReadOnlyModel)

Returns the SqlServerValueGenerationStrategy to use for properties of keys in the model, unless the property has a strategy explicitly set.

SetDatabaseMaxSize(IMutableModel, String)

Sets the maximum size of the database.

SetHiLoSequenceName(IMutableModel, String)

Sets the name to use for the default hi-lo sequence.

SetHiLoSequenceSchema(IMutableModel, String)

Sets the schema to use for the default hi-lo sequence.

SetIdentityIncrement(IMutableModel, Nullable<Int32>)

Sets the default identity increment.

SetIdentitySeed(IMutableModel, Nullable<Int32>)

Sets the default identity seed.

SetIdentitySeed(IMutableModel, Nullable<Int64>)

Sets the default identity seed.

SetPerformanceLevelSql(IMutableModel, String)

Sets the performance level of the database.

SetSequenceNameSuffix(IMutableModel, String)

Sets the suffix to append to the name of automatically created sequences.

SetSequenceSchema(IMutableModel, String)

Sets the schema to use for the default key value generation sequence.

SetServiceTierSql(IMutableModel, String)

Sets the service tier of the database.

SetValueGenerationStrategy(IMutableModel, Nullable<SqlServerValueGenerationStrategy>)

Sets the SqlServerValueGenerationStrategy to use for properties of keys in the model that don't have a strategy explicitly set.

Applies to