Redaguoti

Bendrinti naudojant


Database Providers

Entity Framework Core can access many different databases through plug-in libraries called database providers.

Current providers

Important

EF Core providers are built by a variety of sources. Not all providers are maintained as part of the Microsoft Entity Framework Core Project. When considering a provider, be sure to evaluate quality, licensing, support, etc. to ensure they meet your requirements. Also make sure you review each provider's documentation for detailed version compatibility information.

Important

EF Core providers typically do not work across major versions. For example, a provider released for EF Core 7 will not work with EF Core 8.

NuGet Package Supported database engines Maintainer / Vendor Notes / Requirements For EF Core Useful links
Microsoft.EntityFrameworkCore.SqlServer Azure SQL and SQL Server 2012 onwards EF Core Project (Microsoft) 6, 7, 8 docs
Microsoft.EntityFrameworkCore.Sqlite SQLite 3.7 onwards EF Core Project (Microsoft) 6, 7, 8 docs
Microsoft.EntityFrameworkCore.InMemory EF Core in-memory database EF Core Project (Microsoft) Limitations 6, 7, 8 docs
Microsoft.EntityFrameworkCore.Cosmos Azure Cosmos DB SQL API EF Core Project (Microsoft) 6, 7, 8 docs
Npgsql.EntityFrameworkCore.PostgreSQL PostgreSQL Npgsql Development Team 6, 7, 8 docs
Pomelo.EntityFrameworkCore.MySql MySQL, MariaDB Pomelo Foundation Project 6, 7, 8 readme
MySql.EntityFrameworkCore MySQL MySQL project (Oracle) 6, 7 docs
Oracle.EntityFrameworkCore Oracle DB 11.2 onwards Oracle 6, 7 website
MongoDB.EntityFrameworkCore MongoDB MongoDB 8 docs
Devart.Data.MySql.EFCore MySQL 5 onwards DevArt Paid 6, 7, 8 docs
Devart.Data.Oracle.EFCore Oracle DB 9.2.0.4 onwards DevArt Paid 6, 7, 8 docs
Devart.Data.PostgreSql.EFCore PostgreSQL 8.0 onwards DevArt Paid 6, 7, 8 docs
Devart.Data.SQLite.EFCore SQLite 3 onwards DevArt Paid 6, 7, 8 docs
Devart.Data.DB2.EFCore DB2 DevArt Paid 6, 7, 8 docs
Devart.Data.Bigcommerce.EFCore BigCommerce DevArt Paid 6, 7, 8 docs
Devart.Data.Dynamics.EFCore Microsoft Dynamics 365 DevArt Paid 6, 7, 8 docs
Devart.Data.FreshBooks.EFCore FreshBooks DevArt Paid 6, 7, 8 docs
Devart.Data.Magento.EFCore Magento DevArt Paid 6, 7, 8 docs
Devart.Data.MailChimp.EFCore Mailchimp DevArt Paid 6, 7, 8 docs
Devart.Data.QuickBooks.EFCore QuickBooks DevArt Paid 6, 7, 8 docs
Devart.Data.Salesforce.EFCore Salesforce DevArt Paid 6, 7, 8 docs
Devart.Data.ExactTarget.EFCore Salesforce MC (ExactTarget) DevArt Paid 6, 7, 8 docs
Devart.Data.Sugar.EFCore SugarCRM DevArt Paid 6, 7, 8 docs
Devart.Data.Zoho.EFCore Zoho CRM DevArt Paid 6, 7, 8 docs
MASES.EntityFrameworkCore.KNet Apache Kafka MASES Group Trial, Subscription 6, 7, 8 docs
InterBase InterBase InterBase 6 docs
FirebirdSql.EntityFrameworkCore.Firebird Firebird 3.0 onwards Jiří Činčura 8 docs
IBM.EntityFrameworkCore Db2, Informix IBM Paid, Windows 6 getting started
IBM.EntityFrameworkCore-lnx Db2, Informix IBM Paid, Linux 6 getting started
IBM.EntityFrameworkCore-osx Db2, Informix IBM Paid, macOS 6 getting started
EntityFrameworkCore.Jet Microsoft Access files CirrusRedOrg Windows 6, 7, 8 (Preview) readme
Google.Cloud.EntityFrameworkCore.Spanner Google Cloud Spanner Cloud Spanner Ecosystem Currently in preview 6 tutorial
Teradata.EntityFrameworkCore Teradata Database 16.10 onwards Teradata 3 website
FileContextCore Stores data in files Morris Janatzek For development purposes 3 readme
FileBaseContext Store tables in files k.D.g For development purposes 7, 8 readme
EntityFrameworkCore.SqlServerCompact35 SQL Server Compact 3.5 Erik Ejlskov Jensen .NET Framework 2 wiki
EntityFrameworkCore.SqlServerCompact40 SQL Server Compact 4.0 Erik Ejlskov Jensen .NET Framework 2 wiki
EntityFrameworkCore.OpenEdge Progress OpenEdge Alex Wiese 2 readme

Adding a database provider to your application

Most database providers for EF Core are distributed as NuGet packages, and can be installed as follows:

dotnet add package provider_package_name

Once installed, you will configure the provider in your DbContext, either in the OnConfiguring method or in the AddDbContext method if you are using a dependency injection container. For example, the following line configures the SQL Server provider with the passed connection string:

optionsBuilder.UseSqlServer(
    @"Server=(localdb)\mssqllocaldb;Database=MyDatabase;Trusted_Connection=True;");

Database providers can extend EF Core to enable functionality unique to specific databases. Some concepts are common to most databases, and are included in the primary EF Core components. Such concepts include expressing queries in LINQ, transactions, and tracking changes to objects once they are loaded from the database. Some concepts are specific to a particular provider. For example, the SQL Server provider allows you to configure memory-optimized tables (a feature specific to SQL Server). Other concepts are specific to a class of providers. For example, EF Core providers for relational databases build on the common Microsoft.EntityFrameworkCore.Relational library, which provides APIs for configuring table and column mappings, foreign key constraints, etc. Providers are usually distributed as NuGet packages.

Important

When a new patch version of EF Core is released, it often includes updates to the Microsoft.EntityFrameworkCore.Relational package. When you add a relational database provider, this package becomes a transitive dependency of your application. But many providers are released independently from EF Core and may not be updated to depend on the newer patch version of that package. In order to make sure you will get all bug fixes, it is recommended that you add the patch version of Microsoft.EntityFrameworkCore.Relational as a direct dependency of your application.