RuntimeModel Class

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 class RuntimeModel : Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBase, Microsoft.EntityFrameworkCore.Metadata.Internal.IRuntimeModel
type RuntimeModel = class
    inherit AnnotatableBase
    interface IRuntimeModel
    interface IModel
    interface IReadOnlyModel
    interface IReadOnlyAnnotatable
    interface IAnnotatable
Public Class RuntimeModel
Inherits AnnotatableBase
Implements IRuntimeModel
Inheritance
RuntimeModel
Implements
IAnnotatable IReadOnlyAnnotatable IModel Microsoft.EntityFrameworkCore.Metadata.Internal.IRuntimeModel IReadOnlyModel

Remarks

This is a light-weight implementation that is constructed from a built model and is not meant to be used at design-time.

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.

Constructors

RuntimeModel()

Properties

DebugView

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.

IsReadOnly

Indicates whether the current object is read-only.

(Inherited from AnnotatableBase)
Item[String]

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

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

Methods

AddAnnotation(String, Annotation)

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

(Inherited from AnnotatableBase)
AddAnnotation(String, Object)

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

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

Adds annotations to this object.

(Inherited from AnnotatableBase)
AddAnnotations(IReadOnlyDictionary<String,Object>)

Adds annotations to this object.

(Inherited from AnnotatableBase)
AddEntityType(String, Type, RuntimeEntityType, Boolean, String, ChangeTrackingStrategy, PropertyInfo, Boolean, Object)

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

AddEntityType(String, Type, RuntimeEntityType, Boolean, String, ChangeTrackingStrategy, PropertyInfo, Boolean)

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

AddRuntimeAnnotation(String, Annotation)

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

(Inherited from AnnotatableBase)
AddRuntimeAnnotation(String, Object)

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

(Inherited from AnnotatableBase)
AddRuntimeAnnotations(IEnumerable<Annotation>)

Adds runtime annotations to this object.

(Inherited from AnnotatableBase)
AddRuntimeAnnotations(IReadOnlyDictionary<String,Object>)

Adds runtime annotations to this object.

(Inherited from AnnotatableBase)
AddTypeMappingConfiguration(Type, Nullable<Int32>, Nullable<Boolean>, Nullable<Int32>, Nullable<Int32>, Type, ValueConverter)

Adds configuration for a scalar type.

CreateAnnotation(String, Object)

Creates a new annotation.

(Inherited from AnnotatableBase)
CreateRuntimeAnnotation(String, Object)

Creates a new runtime annotation.

(Inherited from AnnotatableBase)
EnsureMutable()

Throws if the model is read-only.

(Inherited from AnnotatableBase)
EnsureReadOnly()

Throws if the model is not read-only.

(Inherited from AnnotatableBase)
FindAdHocEntityType(Type)

Gets the entity type with the given name. Returns null if no entity type with the given name has been mapped as an ad-hoc type.

FindAnnotation(String)

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

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

FindRuntimeAnnotation(String)

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

(Inherited from AnnotatableBase)
GetAdHocEntityTypes()

Gets all ad-hoc entity types defined in the model.

GetAnnotation(String)

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

(Inherited from AnnotatableBase)
GetAnnotations()

Gets all annotations on the current object.

(Inherited from AnnotatableBase)
GetOrAddAdHocEntityType(RuntimeEntityType)

Adds an ad-hoc entity type to the model.

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 AnnotatableBase)
GetRuntimeAnnotations()

Gets all runtime annotations on the current object.

(Inherited from AnnotatableBase)
OnAnnotationSet(String, Annotation, Annotation)

Called when an annotation was set or removed.

(Inherited from AnnotatableBase)
RemoveAnnotation(String)

Removes the given annotation from this object.

(Inherited from AnnotatableBase)
RemoveRuntimeAnnotation(String)

Removes the given runtime annotation from this object.

(Inherited from AnnotatableBase)
SetAnnotation(String, Annotation, Annotation)

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

(Inherited from AnnotatableBase)
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 AnnotatableBase)
SetRuntimeAnnotation(String, Annotation, Annotation)

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

(Inherited from AnnotatableBase)
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 AnnotatableBase)
SetSkipDetectChanges(Boolean)

Sets a value indicating whether DetectChanges() should be called.

Explicit Interface Implementations

IAnnotatable.AddRuntimeAnnotation(String, Object)

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

(Inherited from AnnotatableBase)
IAnnotatable.FindRuntimeAnnotation(String)

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

(Inherited from AnnotatableBase)
IAnnotatable.GetRuntimeAnnotations()

Gets all the runtime annotations on the current object.

(Inherited from AnnotatableBase)
IAnnotatable.RemoveRuntimeAnnotation(String)

Removes the given runtime annotation from this object.

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

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

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

IModel.FindEntityTypes(Type)

Gets the entity types matching the given type.

IModel.FindTypeMappingConfiguration(Type)

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

IModel.GetEntityTypes()

Gets all entity types defined in the model.

IModel.GetTypeMappingConfigurations()

Gets all the pre-convention configurations.

IModel.IsIndexerMethod(MethodInfo)

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

IReadOnlyAnnotatable.FindAnnotation(String)

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

(Inherited from AnnotatableBase)
IReadOnlyAnnotatable.GetAnnotations()

Gets all annotations on the current object.

(Inherited from AnnotatableBase)
IReadOnlyAnnotatable.Item[String]

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

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

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

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

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.

IReadOnlyModel.FindEntityTypes(Type)

Gets the entity types matching the given type.

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

IReadOnlyModel.GetEntityTypes()

Gets all entity types defined in the model.

IReadOnlyModel.GetPropertyAccessMode()

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

IReadOnlyModel.IsShared(Type)

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

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

IRuntimeModel.RelationalModel

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.

IRuntimeModel.SkipDetectChanges Microsoft.EntityFrameworkCore.Metadata.Internal.IRuntimeModel.SkipDetectChanges

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.

AnnotationsToDebugString(IAnnotatable, Int32)

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

GetRelationalDependencies(IModel, String)

Returns the relational service dependencies.

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.

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

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.

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.

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