EF Core 和 EF6 的功能逐一比較EF Core and EF6 Feature by Feature Comparison

下表比較 EF Core 和 EF6 中可用的功能。The following table compares the features available in EF Core and EF6. 這是概括性的比較,並未列出每一項功能,或嘗試提供相同功能之間運作差異的詳細資料。It is intended to give a high level comparison and does not list every feature, or attempt to give details on possible differences between how the same feature works.

EF Core 行包含功能首次出現時的產品版本號碼。The EF Core column contains the number of the product version in which the feature first appeared.

建立模型Creating a Model EF 6EF 6 EF CoreEF Core
基本類別對應Basic class mapping [是]Yes 1.01.0
含參數的建構函式Constructors with parameters 2.12.1
屬性值轉換Property value conversions 2.12.1
不含索引鍵的對應類型 (查詢類型)Mapped types with no keys (query types) 2.12.1
慣例Conventions [是]Yes 1.01.0
自訂慣例Custom conventions [是]Yes 1.0 (部分)1.0 (partial)
資料註解Data annotations [是]Yes 1.01.0
Fluent APIFluent API [是]Yes 1.01.0
繼承:單表 (TPH)Inheritance: Table per hierarchy (TPH) [是]Yes 1.01.0
繼承:一類一表 (TPT)Inheritance: Table per type (TPT) [是]Yes
繼承:一具象類別一表 (TPC)Inheritance: Table per concrete class (TPC) [是]Yes
陰影狀態屬性Shadow state properties 1.01.0
替代金鑰Alternate keys 1.01.0
多對多但沒有聯結實體Many-to-many without join entity [是]Yes
金鑰產生:資料庫Key generation: Database [是]Yes 1.01.0
金鑰產生:用戶端Key generation: Client 1.01.0
複雜/擁有的型別Complex/owned types [是]Yes 2.02.0
空間資料Spatial data [是]Yes
模型的圖形化視覺效果Graphical visualization of model [是]Yes
圖形化模型編輯器Graphical model editor [是]Yes
模型格式:程式碼Model format: Code [是]Yes 1.01.0
模型格式:EDMX (XML)Model format: EDMX (XML) [是]Yes
從資料庫建立模型:命令列Create model from database: Command line [是]Yes 1.01.0
從資料庫建立模型:VS 精靈Create model from database: VS wizard [是]Yes
從資料庫更新模型Update model from database PartialPartial
全域查詢篩選條件Global query filters 2.02.0
資料表分割Table splitting [是]Yes 2.02.0
實體分割Entity splitting [是]Yes
資料庫純量函式對應Database scalar function mapping Poor 2.02.0
欄位對應Field mapping 1.11.1
查詢資料Querying Data EF6EF6 EF CoreEF Core
LINQ 查詢LINQ queries [是]Yes 1.0 (針對複雜查詢仍在進行中)1.0 (in-progress for complex queries)
可讀取產生的 SQLReadable generated SQL Poor 1.01.0
混合用戶端/伺服器評估Mixed client/server evaluation 1.01.0
GroupBy 轉譯GroupBy translation [是]Yes 2.12.1
載入相關資料:積極Loading related data: Eager [是]Yes 1.01.0
載入相關資料:衍生類型的積極式載入Loading related data: Eager loading for derived types 2.12.1
載入相關資料:消極Loading related data: Lazy [是]Yes 2.12.1
載入相關資料:明確Loading related data: Explicit [是]Yes 1.11.1
原始 SQL 查詢:實體類型Raw SQL queries: Entity types [是]Yes 1.01.0
原始 SQL 查詢:非實體類型 (例如查詢類型)Raw SQL queries: Non-entity types (e.g. query types) [是]Yes 2.12.1
原始的 SQL 查詢:使用 LINQ 撰寫Raw SQL queries: Composing with LINQ 1.01.0
明確地編譯查詢Explicitly compiled queries Poor 2.02.0
以文字為基礎的查詢語言 (例如 Entity SQL)Text-based query language (e.g. Entity SQL) 1.01.0
儲存資料Saving Data EF6EF6 EF CoreEF Core
變更追蹤:快照集Change tracking: Snapshot [是]Yes 1.01.0
變更追蹤:通知Change tracking: Notification [是]Yes 1.01.0
變更追蹤:ProxyChange tracking: Proxies [是]Yes
存取追蹤狀態Accessing tracked state [是]Yes 1.01.0
開放式並行存取Optimistic concurrency [是]Yes 1.01.0
異動Transactions [是]Yes 1.01.0
陳述式的批次處理Batching of statements 1.01.0
預存程序對應Stored procedure mapping [是]Yes
已中斷連線的圖形低階 APIDisconnected graph low-level APIs Poor 1.01.0
已中斷連線的圖形端對端Disconnected graph End-to-end 1.0 (部分)1.0 (partial)
其他功能Other Features EF6EF6 EF CoreEF Core
移轉Migrations [是]Yes 1.01.0
資料庫建立/刪除 APIDatabase creation/deletion APIs [是]Yes 1.01.0
種子資料Seed data [是]Yes 2.12.1
連線恢復功能Connection resiliency [是]Yes 1.11.1
生命週期攔截程序 (事件、攔截)Lifecycle hooks (events, interception) [是]Yes
簡易記錄 (例如 Database.Log)Simple Logging (e.g. Database.Log) [是]Yes
DbContext 共用DbContext pooling 2.02.0
資料庫提供者Database Providers EF6EF6 EF CoreEF Core
SQL ServerSQL Server [是]Yes 1.01.0
MySQLMySQL [是]Yes 1.01.0
PostgreSQLPostgreSQL [是]Yes 1.01.0
OracleOracle [是]Yes 1.0 (1)1.0 (1)
SQLiteSQLite [是]Yes 1.01.0
SQL Server CompactSQL Server Compact [是]Yes 1.0 (2)1.0 (2)
DB2DB2 [是]Yes 1.01.0
FirebirdFirebird [是]Yes 2.02.0
Jet (Microsoft Access)Jet (Microsoft Access) 2.0 (2)2.0 (2)
記憶體內部 (測試用)In-memory (for testing) 1.01.0
平台Platforms EF6EF6 EF CoreEF Core
.NET Framework (主控台、WinForms、WPF、ASP.NET).NET Framework (Console, WinForms, WPF, ASP.NET) [是]Yes 1.01.0
.NET Core (主控台、ASP.NET Core).NET Core (Console, ASP.NET Core) 1.01.0
Mono & XamarinMono & Xamarin 1.0 (進行中)1.0 (in-progress)
UWPUWP 1.0 (進行中)1.0 (in-progress)

1 目前有付費提供者。1 There is currently a paid provider available. Oracle 的免費官方提供者正在開發中。A free official provider for Oracle is being worked on. 2 此提供者只適用於 .NET Framework (不適用於 .NET Core)。2 This provider only works on .NET Framework (not on .NET Core).