資料庫提供者Database Providers

Entity Framework Core 能夠透過稱為資料庫提供者的外掛程式程式庫存取各種不同的資料庫。Entity Framework Core can access many different databases through plug-in libraries called database providers.

目前的提供者Current providers


EF Core 提供者是透過各種來源所建置。EF Core providers are built by a variety of sources. Entity Framework Core 專案的維護並不包含所有提供者。Not all providers are maintained as part of the 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.

NuGet 封裝NuGet Package 支援的資料庫引擎Supported database engines 維護程式/廠商Maintainer / Vendor 注意/需求Notes / Requirements 實用連結Useful links
Microsoft.EntityFrameworkCore.SqlServerMicrosoft.EntityFrameworkCore.SqlServer SQL Server 2008 及更新版本SQL Server 2008 onwards EF Core 專案 (Microsoft)EF Core Project (Microsoft) docsdocs
Microsoft.EntityFrameworkCore.SqliteMicrosoft.EntityFrameworkCore.Sqlite SQLite 3.7 及更新版本SQLite 3.7 onwards EF Core 專案 (Microsoft)EF Core Project (Microsoft) docsdocs
Microsoft.EntityFrameworkCore.InMemoryMicrosoft.EntityFrameworkCore.InMemory EF Core 記憶體內部資料庫EF Core in-memory database EF Core 專案 (Microsoft)EF Core Project (Microsoft) 僅供測試For testing only docsdocs
Microsoft.EntityFrameworkCore.CosmosMicrosoft.EntityFrameworkCore.Cosmos Azure Cosmos DB SQL APIAzure Cosmos DB SQL API EF Core 專案 (Microsoft)EF Core Project (Microsoft) 只有預覽Preview only 部落格blog
Npgsql.EntityFrameworkCore.PostgreSQLNpgsql.EntityFrameworkCore.PostgreSQL PostgreSQLPostgreSQL Npgsql 開發小組Npgsql Development Team docsdocs
Pomelo.EntityFrameworkCore.MySqlPomelo.EntityFrameworkCore.MySql MySQL、MariaDBMySQL, MariaDB Pomelo Foundation 專案Pomelo Foundation Project 讀我檔案readme
Pomelo.EntityFrameworkCore.MyCatPomelo.EntityFrameworkCore.MyCat MyCAT 伺服器MyCAT Server Pomelo Foundation 專案Pomelo Foundation Project 只有發行前版本Prerelease only 讀我檔案readme
EntityFrameworkCore.SqlServerCompact40EntityFrameworkCore.SqlServerCompact40 SQL Server Compact 4.0SQL Server Compact 4.0 Erik Ejlskov JensenErik Ejlskov Jensen .NET Framework.NET Framework wikiwiki
EntityFrameworkCore.SqlServerCompact35EntityFrameworkCore.SqlServerCompact35 SQL Server Compact 3.5SQL Server Compact 3.5 Erik Ejlskov JensenErik Ejlskov Jensen .NET Framework.NET Framework wikiwiki
EntityFrameworkCore.JetEntityFrameworkCore.Jet Microsoft Access 檔案Microsoft Access files BubiBubi .NET Framework.NET Framework 讀我檔案readme
MySql.Data.EntityFrameworkCoreMySql.Data.EntityFrameworkCore MySQLMySQL MySQL 專案 (Oracle)MySQL project (Oracle) docsdocs
FirebirdSql.EntityFrameworkCore.FirebirdFirebirdSql.EntityFrameworkCore.Firebird Firebird 2.5 及 3.xFirebird 2.5 and 3.x Jiří ČinčuraJiří Činčura docsdocs
EntityFrameworkCore.FirebirdSqlEntityFrameworkCore.FirebirdSql Firebird 2.5 及 3.xFirebird 2.5 and 3.x Rafael AlmeidaRafael Almeida wikiwiki
IBM.EntityFrameworkCoreIBM.EntityFrameworkCore Db2、InformixDb2, Informix IBMIBM Windows 版本Windows version 部落格blog
IBM.EntityFrameworkCore-lnxIBM.EntityFrameworkCore-lnx Db2、InformixDb2, Informix IBMIBM Linux 版本Linux version 部落格blog
IBM.EntityFrameworkCore-osxIBM.EntityFrameworkCore-osx Db2、InformixDb2, Informix IBMIBM macOS 版本macOS version 部落格blog
EntityFrameworkCore.OpenEdgeEntityFrameworkCore.OpenEdge Progress OpenEdgeProgress OpenEdge Alex WieseAlex Wiese 讀我檔案readme
Devart.Data.Oracle.EFCoreDevart.Data.Oracle.EFCore Oracle 及更新版本Oracle onwards DevArtDevArt 已支付Paid docsdocs
Devart.Data.PostgreSql.EFCoreDevart.Data.PostgreSql.EFCore PostgreSQL 8.0 及更新版本PostgreSQL 8.0 onwards DevArtDevArt 已支付Paid docsdocs
Devart.Data.SQLite.EFCoreDevart.Data.SQLite.EFCore SQLite 3 及更新版本SQLite 3 onwards DevArtDevArt 已支付Paid docsdocs
Devart.Data.MySql.EFCoreDevart.Data.MySql.EFCore MySQL 5 及更新版本MySQL 5 onwards DevArtDevArt 已支付Paid docsdocs

未來的提供者Future Providers

Cosmos DBCosmos DB

我們正為 Cosmos DB 中的 SQL API 開發 EF Core 提供者。We have been developing an EF Core provider for the SQL API in Cosmos DB. 這會是我們產生的首個完整文件導向資料庫提供者,而我們會從這次實踐中得到的經驗會用來改善 EF Core 未來版本 (可能還有其他非關聯性提供者) 的設計。This will be the first complete document-oriented database provider we have produced, and the learnings from this exercise are going to inform improvements in the design of future releases of EF Core and possibly other non-relational providers. 您可在 NuGet 資源庫取得預覽。A preview is available on the NuGet Gallery.


Oracle .NET 已宣布將於 2018 第三季左右發行 EF Core 的第一方提供者。The Oracle .NET team has announced they are planning to release a first-party provider for EF Core approximately in the third quarter of 2018. 如需詳細資訊,請參閱其 .NET Core 與 Entity Framework Core 的方針聲明See their statement of direction for .NET Core and Entity Framework Core for more information. 請將任何有關此提供者的問題 (包含版本時間軸) 指向 Oracle 社群網站Please direct any questions about this provider, including the release timeline, to the Oracle Community Site.

與此同時,EF 小組也生產了適用於 Oracle 資料庫的範例 EF Core 提供者In the meanwhile, the EF team has produced a sample EF Core provider for Oracle databases. 這個專案的目的是不要生產 Microsoft 所擁有的 EF Core 提供者。The purpose of the project is not to produce an EF Core provider owned by Microsoft. 我們展開了這項專案,來找出 EF Core 關聯式與基礎功能之間的差距並加以解決,以改善 Oracle 的支援。We started the project to identify gaps in EF Core's relational and base functionality which we needed to address in order to better support Oracle. 這應有助於 Oracle 或其他協力廠商開始為 EF Core 開發 Oracle 提供者。It should also help Oracle or third parties jumpstart the development of Oracle providers for EF Core.

我們會考慮採用能夠改善範例實作的貢獻。We will consider contributions that improve the sample implementation. 同時也歡迎並鼓勵社群以範例作為出發點參與,來為 EF Core 建立開放原始碼 Oracle 提供者。We would also welcome and encourage a community effort to create an open-source Oracle provider for EF Core, using the sample as a starting point.

將資料庫提供者新增至應用程式Adding a database provider to your application

大多數 EF Core 資料庫提供者皆以 NuGet 套件的形式散發。Most database providers for EF Core are distributed as NuGet packages. 這表示您可在命令列中使用 dotnet 工具加以安裝:This means they can be installed using the dotnet tool in the command line:

dotnet add package provider_package_name

或者在 Visual Studio 中使用 NuGet 的套件管理員主控台:Or in Visual Studio, using NuGet's Package Manager Console:

install-package provider_package_name

若您使用相依性插入容器,請在安裝完成後以 OnConfiguring 方式或 AddDbContext 方式在 DbContext 中設定提供者。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. 例如,下列程式行會以傳遞的連接字串設定 SQL Server 提供者:For example, the following line configures the SQL Server provider with the passed connection string:


資料庫提供者能夠延伸 EF Core,來啟用特定資料庫套有的功能。Database providers can extend EF Core to enable functionality unique to specific databases. 有些概念通用於大多數資料庫,並且包含在主要 EF Core 元件中。Some concepts are common to most databases, and are included in the primary EF Core components. 這類概念包含以 LINQ 表示查詢、異動,以及在從資料庫載入物件之後追蹤其變更。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. 例如,SQL Server 提供者可讓您設定記憶體最佳化資料表 (SQL Server 特有的功能)。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. 例如,關聯式資料庫的 EF Core 提供者是根據一般 Microsoft.EntityFrameworkCore.Relational 程式庫所建置,而此程式庫提供 API 來設定資料表和資料行對應、外部索引鍵條件約束等等。提供者通常會以 NuGet 套件的形式散發。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.


當 EF Core 的新修補程式版本發行時,通常會包含 Microsoft.EntityFrameworkCore.Relational 套件的更新。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. 但是,因為許多提供者皆從 EF Core 獨立發行,所以可能不會更新為相依於該套件的較新修補程式版本。But many providers are released independently from EF Core and may not be updated to depend on the newer patch version of that package. 為了確保您能夠修正所有 Bug,建議您將 Microsoft.EntityFrameworkCore.Relational 的修補程式版本新增為應用程式的直接相依性。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.