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

The service lifetime is Scoped. This means that each DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.

public interface IModel : Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable
type IModel = interface
    interface IAnnotatable
Public Interface IModel
Implements IAnnotatable
Derived
Implements

Properties

Item[String]

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

(Inherited from IAnnotatable)

Methods

FindAnnotation(String)

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

(Inherited from IAnnotatable)
FindEntityType(String)

Gets the entity type 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.

GetAnnotations()

Gets all annotations on the current object.

(Inherited from IAnnotatable)
GetEntityTypes()

Gets all entity types defined in the model.

Extension Methods

GetDefaultContainer(IModel)

Returns the default container name.

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)

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)

Gets the entity types matching the given name.

GetEntityTypes(IModel, Type)

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)

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

HasEntityTypeWithDefiningNavigation(IModel, Type)

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.

Relational(IModel)

Gets the relational database specific metadata for a model.

FindDbFunction(IModel, MethodInfo)

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

FindDbFunction(IModel, String)

Finds an IDbFunction that is mapped to the method represented by the given name.

FindSequence(IModel, String, String)

Finds an ISequence with the given name.

GetCollation(IModel)

Returns the database collation.

GetDbFunctions(IModel)

Returns all IDbFunctions contained in the model.

GetDefaultSchema(IModel)

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.

GetRelationalModel(IModel)

Returns the database model.

GetSequences(IModel)

Returns all ISequences contained in the model.

Sqlite(IModel)

Gets the SQLite specific metadata for a model.

SqlServer(IModel)

Gets the SQL Server specific metadata for a model.

GetDatabaseMaxSize(IModel)

Returns the maximum size of the database.

GetHiLoSequenceName(IModel)

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)

GetIdentityIncrement(IModel)

Returns the default identity increment.

GetIdentitySeed(IModel)

Returns the default identity seed.

GetPerformanceLevelSql(IModel)

Returns the performance level of the database.

GetServiceTierSql(IModel)

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.

Applies to