次の方法で共有


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.

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

Remarks

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.

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.

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

AddRuntimeAnnotation(String, Object)

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

(Inherited from IAnnotatable)
AnnotationsToDebugString(Int32)

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

(Inherited from IReadOnlyAnnotatable)
FindAnnotation(String)

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

(Inherited from IReadOnlyAnnotatable)
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.

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

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

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.

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.

FindTypeMappingConfiguration(Type)

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

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)
GetEmbeddedDiscriminatorName()

Gets the name to use for discriminator properties embedded in JSON documents. The default is "$type".

(Inherited from IReadOnlyModel)
GetEntityTypes()

Gets all entity types defined in the model.

GetModelDependencies()

Gets the runtime service dependencies.

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.

IsIndexerMethod(MethodInfo)

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

IsShared(Type)

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

(Inherited from IReadOnlyModel)
RemoveRuntimeAnnotation(String)

Removes the given runtime annotation from this object.

(Inherited from IAnnotatable)
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.

GetDiscriminatorInKey(IReadOnlyModel)

Returns a value indicating whether the entity type discriminator should be included in the JSON "id" value. Prior to EF Core 9, it was always included. Starting with EF Core 9, it is not included by default.

GetHasShadowIds(IReadOnlyModel)

Returns a value indicating whether the setting for always creating the "__id" property can be set from the current configuration source

GetThroughput(IReadOnlyModel)

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

GetRelationalDependencies(IModel, String)

Returns the relational service dependencies.

Scaffolding(IModel)
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.

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.

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.

Relational(IModel)

Gets the relational database specific metadata for a model.

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(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(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(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(IReadOnlyModel)

Returns all sequences contained in the model.

GetFluentApiCalls(IModel, IAnnotationCodeGenerator)

Gets the fluent API calls to configure a 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.

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.

Applies to