撰寫資料庫提供者Writing a Database Provider

撰寫 Entity Framework Core 資料庫提供者的相關資訊,請參閱因此您想要撰寫的 EF Core 提供者Arthur VickersFor information about writing an Entity Framework Core database provider, see So you want to write an EF Core provider by Arthur Vickers.

注意

這些文章有尚未更新從 EF Core 1.1,而且已有重大變更自那時起問題 681正在追蹤更新這份文件。These posts have not been updated since EF Core 1.1 and there have been significant changes since that time Issue 681 is tracking updates to this documentation.

EF Core 程式碼基底是開放原始碼,並包含數個可做為參考資料庫提供者。The EF Core codebase is open source and contains several database providers that can be used as a reference. 您可以找到原始程式碼 https://github.com/aspnet/EntityFrameworkCoreYou can find the source code at https://github.com/aspnet/EntityFrameworkCore. 它也可能有助於查看程式碼常用的協力廠商提供者,例如NpgsqlPomelo MySQL,並SQL Server CompactIt may also be helpful to look at the code for commonly used third-party providers, such as Npgsql, Pomelo MySQL, and SQL Server Compact. 特別是,這些專案已設定,以從擴充,並在 NuGet 上執行我們所發行的功能測試。In particular, these projects are setup to extend from and run functional tests that we publish on NuGet. 強烈建議這種安裝程式。This kind of setup is strongly recommended.

保持最新提供者變更Keeping up-to-date with provider changes

在 2.1 版之後,以啟動工作,我們建立了之變更的記錄,可能需要在提供者程式碼中對應的變更。Starting with work after the 2.1 release, we have created a log of changes that may need corresponding changes in provider code. 這被為了協助更新現有的提供者時,才能使用 EF Core 的新版本。This is intended to help when updating an existing provider to work with a new version of EF Core.

在 2.1 之前, 我們會使用 providers-beware providers-fyi 我們的 GitHub 問題和類似的目的的提取要求中的標籤。Prior to 2.1, we used the providers-beware and providers-fyi labels on our GitHub issues and pull requests for a similar purpose. 我們將 continiue 問題上使用這些標籤,來指出在指定的版本中的工作項目可能也需要在提供者中的工作。We will continiue to use these lables on issues to give an indication which work items in a given release may also require work to be done in providers. Aproviders-beware標籤通常表示工作項目的實作可能會中斷提供者,雖然providers-fyi標籤通常會表示提供者並不會中斷,但程式碼可能需要變更,例如,若要啟用新功能。A providers-beware label typically means that the implementation of an work item may break providers, while a providers-fyi label typically means that providers will not be broken, but code may need to be changed anyway, for example, to enable new functionality.

建議的命名的協力廠商提供者Suggested naming of third party providers

我們建議使用 NuGet 套件的下列命名。We suggest using the following naming for NuGet packages. 這是與 EF Core 小組所傳遞的封裝的名稱一致。This is consistent with the names of packages delivered by the EF Core team.

<Optional project/company name>.EntityFrameworkCore.<Database engine name>

例如: For example:

  • Microsoft.EntityFrameworkCore.SqlServer
  • Npgsql.EntityFrameworkCore.PostgreSQL
  • EntityFrameworkCore.SqlServerCompact40