Microsoft.EntityFrameworkCore Namespace

Classes

BackingFieldAttribute

Names the backing field associated with this property or navigation property.

ChangeTrackerExtensions

Extension methods for ChangeTracker.

CommentAttribute

Marks a class, property or field with a comment to be set on the corresponding database table or column.

ConventionAnnotatableExtensions

Extension methods for IConventionAnnotatable.

ConventionEntityTypeExtensions

Extension methods for IConventionEntityType.

ConventionForeignKeyExtensions

Extension methods for IConventionForeignKey.

ConventionKeyExtensions

Extension methods for IConventionKey.

ConventionModelExtensions

Extension methods for IConventionModel.

ConventionNavigationExtensions

Extension methods for IConventionNavigation.

ConventionPropertyBaseExtensions

Extension methods for IConventionPropertyBase.

ConventionPropertyExtensions

Extension methods for IConventionProperty.

ConventionTypeBaseExtensions

Extension methods for IConventionTypeBase.

CosmosDatabaseFacadeExtensions

Extension methods for the DatabaseFacade returned from Database that can be used only with the Cosmos provider.

CosmosDbContextOptionsExtensions

Cosmos-specific extension methods for DbContextOptionsBuilder.

CosmosEntityTypeBuilderExtensions

Cosmos-specific extension methods for EntityTypeBuilder.

CosmosEntityTypeExtensions

Entity type extension methods for Cosmos metadata.

CosmosModelBuilderExtensions

Cosmos-specific extension methods for ModelBuilder.

CosmosModelExtensions

Model extension methods for Cosmos metadata.

CosmosPropertyBuilderExtensions

Cosmos-specific extension methods for PropertyBuilder.

CosmosPropertyExtensions

Property extension methods for Cosmos metadata.

CosmosQueryableExtensions

Cosmos-specific extension methods for LINQ queries.

DbContext

A DbContext instance represents a session with the database and can be used to query and save instances of your entities. DbContext is a combination of the Unit Of Work and Repository patterns.

Entity Framework Core does not support multiple parallel operations being run on the same DbContext instance. This includes both parallel execution of async queries and any explicit concurrent use from multiple threads. Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute in parallel. See Avoiding DbContext threading issues for more information.

DbContextOptions

The options to be used by a DbContext. You normally override OnConfiguring(DbContextOptionsBuilder) or use a DbContextOptionsBuilder to create instances of this class and it is not designed to be directly constructed in your application code.

DbContextOptions<TContext>

The options to be used by a DbContext. You normally override OnConfiguring(DbContextOptionsBuilder) or use a DbContextOptionsBuilder<TContext> to create instances of this class and it is not designed to be directly constructed in your application code.

DbContextOptionsBuilder

Provides a simple API surface for configuring DbContextOptions. Databases (and other extensions) typically define extension methods on this object that allow you to configure the database connection (and other options) to be used for a context.

You can use DbContextOptionsBuilder to configure a context by overriding OnConfiguring(DbContextOptionsBuilder) or creating a DbContextOptions externally and passing it to the context constructor.

DbContextOptionsBuilder<TContext>

Provides a simple API surface for configuring DbContextOptions<TContext>. Databases (and other extensions) typically define extension methods on this object that allow you to configure the database connection (and other options) to be used for a context.

You can use DbContextOptionsBuilder to configure a context by overriding OnConfiguring(DbContextOptionsBuilder) or creating a DbContextOptions externally and passing it to the context constructor.

DbFunctionAttribute

Maps a static CLR method to a database function so that the CLR method may be used in LINQ queries. By convention uses the .NET method name as name of the database function and the default schema.

DbFunctions

Provides CLR methods that get translated to database functions when used in LINQ to Entities queries. The methods on this class are accessed via Functions.

DbFunctionsExtensions

Provides CLR methods that get translated to database functions when used in LINQ to Entities queries. The methods on this class are accessed via Functions.

DbLoggerCategory

An API for getting logger categories in an Intellisense/tab-completion friendly manner.

Get an Entity Framework Core logger category using its Name property. For example, LoggerCategory.Database.Sql.Name.

Use these types with IDiagnosticsLogger<TLoggerCategory> or IDiagnosticsLogger<TLoggerCategory> to create a logger.

DbLoggerCategory.ChangeTracking

Logger category for messages from change detection and tracking.

DbLoggerCategory.Database

Logger categories for messages related to database interactions.

DbLoggerCategory.Database.Command

Logger category for command execution, including SQL sent to the database.

DbLoggerCategory.Database.Connection

Logger category for messages related to connection operations.

DbLoggerCategory.Database.Transaction

Logger category for messages related to transaction operations.

DbLoggerCategory.Infrastructure

Logger category for miscellaneous messages from the Entity Framework infrastructure.

DbLoggerCategory.Migrations

Logger category messages from Migrations.

DbLoggerCategory.Model

Logger categories for messages related to model building and metadata.

DbLoggerCategory.Model.Validation

Logger category for messages from model validation.

DbLoggerCategory.Query

Logger category for messages related to queries, excluding the generated SQL, which is in the DbLoggerCategory.Database.Command category.

DbLoggerCategory.Scaffolding

Logger category for messages from scaffolding/reverse engineering.

DbLoggerCategory.Update

Logger category for messages related to SaveChanges(), excluding messages specifically relating to database interactions which are covered by the DbLoggerCategory.Database categories.

DbQuery<TQuery>

A DbQuery<TQuery> can be used to query instances of TQuery. LINQ queries against a DbQuery<TQuery> will be translated into queries against the database.

The results of a LINQ query against a DbQuery<TQuery> will contain the results returned from the database and may not reflect changes made in the context that have not been persisted to the database. For example, the results will not contain newly added views and may still contain views that are marked for deletion.

Depending on the database being used, some parts of a LINQ query against a DbQuery<TQuery> may be evaluated in memory rather than being translated into a database query.

DbQuery<TQuery> objects are usually obtained from a DbQuery<TQuery> property on a derived DbContext or from the Query<TQuery>() method.

DbSet<TEntity>

A DbSet<TEntity> can be used to query and save instances of TEntity. LINQ queries against a DbSet<TEntity> will be translated into queries against the database.

The results of a LINQ query against a DbSet<TEntity> will contain the results returned from the database and may not reflect changes made in the context that have not been persisted to the database. For example, the results will not contain newly added entities and may still contain entities that are marked for deletion.

Depending on the database being used, some parts of a LINQ query against a DbSet<TEntity> may be evaluated in memory rather than being translated into a database query.

DbSet<TEntity> objects are usually obtained from a DbSet<TEntity> property on a derived DbContext or from the Set<TEntity>() method.

Entity Framework Core does not support multiple parallel operations being run on the same DbContext instance. This includes both parallel execution of async queries and any explicit concurrent use from multiple threads. Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute in parallel. See Avoiding DbContext threading issues for more information.

DbUpdateConcurrencyException

An exception that is thrown when a concurrency violation is encountered while saving to the database. A concurrency violation occurs when an unexpected number of rows are affected during save. This is usually because the data in the database has been modified since it was loaded into memory.

DbUpdateException

An exception that is thrown when an error is encountered while saving to the database.

EF

Static methods that are useful in application code where there is not an EF type for the method to be accessed from. For example, referencing a shadow state property in a LINQ query.

EntityFrameworkQueryableExtensions

Entity Framework LINQ related extension methods.

EntityTypeConfigurationAttribute

Specifies the configuration type for the entity type.

EntityTypeExtensions

Entity type extension methods for IReadOnlyEntityType.

ExecutionStrategyExtensions

Extension methods for IExecutionStrategy

ForeignKeyExtensions

Extension methods for IReadOnlyForeignKey.

IndexAttribute

Specifies an index to be generated in the database.

IndexExtensions

Extension methods for IIndex.

InMemoryDatabaseFacadeExtensions

In-memory specific extension methods for Database.

InMemoryDbContextOptionsExtensions

In-memory specific extension methods for DbContextOptionsBuilder.

InMemoryEntityTypeBuilderExtensions

Extension methods for EntityTypeBuilder for the in-memory provider.

InMemoryEntityTypeExtensions

Extension methods for IReadOnlyEntityType for the in-memory provider.

KeyExtensions

Extension methods for IReadOnlyKey.

KeylessAttribute

Marks a type as keyless entity.

ModelBuilder

Provides a simple API surface for configuring a IMutableModel that defines the shape of your entities, the relationships between them, and how they map to the database.

You can use ModelBuilder to construct a model for a context by overriding OnModelCreating(ModelBuilder) on your derived context. Alternatively you can create the model externally and set it on a DbContextOptions instance that is passed to the context constructor.

ModelConfigurationBuilder

Provides a simple API surface for setting defaults and configuring conventions before they run.

You can use ModelConfigurationBuilder to configure the conventions for a context by overriding ConfigureConventions(ModelConfigurationBuilder) on your derived context. Alternatively you can create the model externally and set it on a DbContextOptions instance that is passed to the context constructor.

ModelCreationDependencies

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.

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.

ModelExtensions

Extension methods for IReadOnlyModel.

MutableAnnotatableExtensions

Extension methods for IMutableAnnotatable.

MutableEntityTypeExtensions

Extension methods for IMutableEntityType.

MutableForeignKeyExtensions

Extension methods for IMutableForeignKey.

MutableKeyExtensions

Extension methods for IMutableKey.

MutableModelExtensions

Extension methods for IMutableModel.

MutableNavigationExtensions

Extension methods for IMutableNavigation.

MutablePropertyBaseExtensions

Extension methods for IMutablePropertyBase.

MutablePropertyExtensions

Extension methods for IMutableProperty.

MutableTypeBaseExtensions

Extension methods for IMutableTypeBase.

NavigationExtensions

Extension methods for IReadOnlyNavigation.

ObservableCollectionExtensions

Extension methods for ObservableCollection<T>.

OwnedAttribute

Marks a type as owned. All references to this type will be configured as owned entity types.

PrecisionAttribute

Configures the precision of data that is allowed in this property. For example, if the property is a Decimal then this is the maximum number of digits.

PropertyBaseExtensions

Extension methods for IReadOnlyPropertyBase.

PropertyExtensions

Extension methods for IReadOnlyProperty.

ProxiesExtensions

Extension methods related to use of proxies with Entity Framework Core.

RelationalCollectionOwnershipBuilderExtensions

Relational database specific extension methods for CollectionOwnershipBuilder.

RelationalDatabaseFacadeExtensions

Extension methods for the DatabaseFacade returned from Database that can be used only with relational database providers.

RelationalDbFunctionsExtensions

Provides CLR methods that get translated to database functions when used in LINQ to Entities queries. The methods on this class are accessed via Functions.

RelationalEntityTypeBuilderExtensions

Relational database specific extension methods for EntityTypeBuilder.

RelationalEntityTypeExtensions

Entity type extension methods for relational database metadata.

RelationalForeignKeyBuilderExtensions

Relational database specific extension methods for relationship builders.

RelationalForeignKeyExtensions

Foreign key extension methods for relational database metadata.

RelationalIndexBuilderExtensions

Relational database specific extension methods for IndexBuilder.

RelationalIndexExtensions

Index extension methods for relational database metadata.

RelationalKeyBuilderExtensions

Relational database specific extension methods for KeyBuilder.

RelationalKeyExtensions

Key extension methods for relational database metadata.

RelationalMetadataExtensions

Relational database specific extension methods for metadata.

RelationalModelBuilderExtensions

Relational database specific extension methods for ModelBuilder.

RelationalModelExtensions

Relational-specific model extension methods.

RelationalOwnedNavigationBuilderExtensions

Relational database specific extension methods for OwnedNavigationBuilder.

RelationalPropertiesConfigurationBuilderExtensions

Relational database specific extension methods for PropertiesConfigurationBuilder.

RelationalPropertyBuilderExtensions

Relational database specific extension methods for PropertyBuilder.

RelationalPropertyExtensions

Property extension methods for relational database metadata.

RelationalQueryableExtensions

Relational database specific extension methods for LINQ queries.

RelationalQueryTypeBuilderExtensions

Relational database specific extension methods for QueryTypeBuilder.

RelationalReferenceCollectionBuilderExtensions

Relational database specific extension methods for ReferenceCollectionBuilder.

RelationalReferenceOwnershipBuilderExtensions

Relational database specific extension methods for ReferenceOwnershipBuilder.

RelationalReferenceReferenceBuilderExtensions

Relational database specific extension methods for ReferenceReferenceBuilder.

RelationalTypeMappingConfigurationBuilderExtensions

Relational database specific extension methods for TypeMappingConfigurationBuilder.

SaveChangesEventArgs

Base event arguments for the DbContext.SaveChanges and DbContext.SaveChangesAsync events.

SaveChangesFailedEventArgs

Event arguments for the SaveChangesFailed event.

SavedChangesEventArgs

Event arguments for the SavedChanges event.

SavingChangesEventArgs

Event arguments for the SavingChanges event.

ServicePropertyExtensions

Extension methods for IServiceProperty.

SkipNavigationExtensions

Extension methods for ISkipNavigation.

SqliteDatabaseFacadeExtensions

SQLite specific extension methods for Database.

SqliteDbContextOptionsBuilderExtensions

SQLite specific extension methods for DbContextOptionsBuilder.

SqliteDbFunctionsExtensions

Contains extension methods on DbFunctions for the Microsoft.EntityFrameworkCore.Sqlite provider.

SqliteEntityTypeBuilderExtensions

SQLite specific extension methods for EntityTypeBuilder.

SqliteIndexBuilderExtensions

SQLite specific extension methods for IndexBuilder.

SqliteKeyBuilderExtensions

SQLite specific extension methods for KeyBuilder.

SqliteMetadataExtensions

SQLite specific extension methods for metadata.

SqliteNetTopologySuiteDbContextOptionsBuilderExtensions

NetTopologySuite specific extension methods for SqliteDbContextOptionsBuilder.

SqliteNetTopologySuitePropertyBuilderExtensions

SQLite and NetTopologySuite specific extension methods for PropertyBuilder.

SqlitePropertyBuilderExtensions

SQLite-specific extension methods for PropertyBuilder.

SqlitePropertyExtensions

Extension methods for IProperty for SQLite metadata.

SqliteReferenceCollectionBuilderExtensions

SQLite specific extension methods for ReferenceCollectionBuilder.

SqliteReferenceReferenceBuilderExtensions

SQLite specific extension methods for ReferenceReferenceBuilder.

SqlServerCollectionOwnershipBuilderExtensions

SQL Server specific extension methods for CollectionOwnershipBuilder.

SqlServerDatabaseFacadeExtensions

SQL Server specific extension methods for Database.

SqlServerDbContextOptionsExtensions

SQL Server specific extension methods for DbContextOptionsBuilder.

SqlServerDbFunctionsExtensions

Provides CLR methods that get translated to database functions when used in LINQ to Entities queries. The methods on this class are accessed via Functions.

SqlServerDbSetExtensions

Sql Server database specific extension methods for LINQ queries rooted in DbSet.

SqlServerEntityTypeBuilderExtensions

SQL Server specific extension methods for EntityTypeBuilder.

SqlServerEntityTypeExtensions

Entity type extension methods for SQL Server-specific metadata.

SqlServerIndexBuilderExtensions

SQL Server specific extension methods for IndexBuilder.

SqlServerIndexExtensions

Index extension methods for SQL Server-specific metadata.

SqlServerKeyBuilderExtensions

SQL Server specific extension methods for KeyBuilder.

SqlServerKeyExtensions

Key extension methods for SQL Server-specific metadata.

SqlServerMetadataExtensions

SQL Server specific extension methods for metadata.

SqlServerModelBuilderExtensions

SQL Server specific extension methods for ModelBuilder.

SqlServerModelExtensions

Model extension methods for SQL Server-specific metadata.

SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions

NetTopologySuite specific extension methods for SqlServerDbContextOptionsBuilder.

SqlServerPropertyBuilderExtensions

SQL Server specific extension methods for PropertyBuilder.

SqlServerPropertyExtensions

Property extension methods for SQL Server-specific metadata.

SqlServerReferenceCollectionBuilderExtensions

SQL Server specific extension methods for ReferenceCollectionBuilder.

SqlServerReferenceOwnershipBuilderExtensions

SQL Server specific extension methods for ReferenceOwnershipBuilder.

SqlServerReferenceReferenceBuilderExtensions

SQL Server specific extension methods for ReferenceReferenceBuilder.

SqlServerRetryingExecutionStrategy

An IExecutionStrategy implementation for retrying failed executions on SQL Server.

This strategy is specifically tailored to SQL Server (including SQL Azure). It is pre-configured with error numbers for transient errors that can be retried. Additional error numbers to retry on can also be supplied.

SqlServerTableBuilderExtensions

SQL Server specific extension methods for TableBuilder.

TypeBaseExtensions

Extension methods for IReadOnlyTypeBase.

UnicodeAttribute

Configures the property as capable of persisting unicode characters.

WarningConfigurationBuilderExtensions

Relational database specific extension methods for WarningsConfigurationBuilder.

Structs

DbContextId

A unique identifier for the context instance and pool lease, if any.

This identifier is primarily intended as a correlation ID for logging and debugging such that it is easy to identify that multiple events are using the same or different context instances.

RawSqlString

A string representing a raw SQL query. This type enables overload resolution between the regular and interpolated FromSql<TEntity>(IQueryable<TEntity>, RawSqlString, Object[]) and ExecuteSqlCommand(DatabaseFacade, RawSqlString, Object[])

Interfaces

IDbContextFactory<TContext>

Defines a factory for creating DbContext instances.

IEntityTypeConfiguration<TEntity>

Allows configuration for an entity type to be factored into a separate class, rather than in-line in OnModelCreating(ModelBuilder). Implement this interface, applying configuration for the entity in the Configure(EntityTypeBuilder<TEntity>) method, and then apply the configuration to the model using ApplyConfiguration<TEntity>(IEntityTypeConfiguration<TEntity>) in OnModelCreating(ModelBuilder).

IQueryTypeConfiguration<TQuery>

Allows configuration for a query type to be factored into a separate class, rather than in-line in OnModelCreating(ModelBuilder). Implement this interface, applying configuration for the query in the Configure(QueryTypeBuilder<TQuery>) method, and then apply the configuration to the model using ApplyConfiguration<TQuery>(IQueryTypeConfiguration<TQuery>) in OnModelCreating(ModelBuilder).

Enums

ChangeTrackingStrategy

Indicates how the context detects changes to properties for an instance of the entity type.

DeleteBehavior

Indicates how a delete operation is applied to dependent entities in a relationship when the principal is deleted or the relationship is severed.

Behaviors in the database are dependent on the database schema being created appropriately. Using Entity Framework Migrations or EnsureCreated() will create the appropriate schema.

Note that the in-memory behavior for entities that are currently tracked by the DbContext can be different from the behavior that happens in the database.

EntityState

The state in which an entity is being tracked by a context.

PropertyAccessMode

Pass a value from this enum to UsePropertyAccessMode(PropertyAccessMode), UsePropertyAccessMode(PropertyAccessMode), or UsePropertyAccessMode(PropertyAccessMode) to change whether the property or backing field will be used when reading and writing to a property or field.

The default behavior is PreferField. Prior to EF Core 3.0, the default behavior was PreferFieldDuringConstruction.

QuerySplittingBehavior

Indicates how the related collections in a query should be loaded from database.

QueryTrackingBehavior

Indicates how the results of a query are tracked by the ChangeTracker.

WarningBehavior

The runtime behavior of warnings generated by Entity Framework