EF Core 1.0 中包含的功能Features included in EF Core 1.0


.NET Framework 4.5.1.NET Framework 4.5.1

包括主控台、 WPF、WinForms、ASP.NET 4 等。Includes Console, WPF, WinForms, ASP.NET 4, etc.

.NET Standard 1.3.NET Standard 1.3

包括以 Windows、OSX 和 Linux 上的 .NET Framework 與 .NET Core 兩者為目標的 ASP.NET Core。Including ASP.NET Core targeting both .NET Framework and .NET Core on Windows, OSX, and Linux.


基本模型建構Basic modelling

以具有常見純量型別 (intstring 等) get/set 屬性的 POCO 實體為基礎。Based on POCO entities with get/set properties of common scalar types (int, string, etc.).

關聯性與瀏覽屬性Relationships and navigation properties

您可以在以外部索引鍵為基礎的模型中指定一對多與一對零或一對一關聯性。One-to-many and One-to-zero-or-one relationships can be specified in the model based on a foreign key. 簡單集合或參考型別的瀏覽屬性可以與這些關聯性關聯。Navigation properties of simple collection or reference types can be associated with these relationships.

內建慣例Built-in conventions

這些會根據實體類別的圖形建置初始模型。These build an initial model based on the shape of the entity classes.

Fluent APIFluent API

可讓您在您的上下文中覆寫 OnModelCreating 方法,以進一步設定由慣例所探索到的模型。Allows you to override the OnModelCreating method on your context to further configure the model that was discovered by convention.

資料註解Data annotations

這些屬性可新增到您的實體類別/屬性,而且將會影響 EF 模型 (亦即,新增 [必要] 可讓 EF 知道該屬性是必要屬性)。Are attributes that can be added to your entity classes/properties and will influence the EF model (i.e. adding [Required] will let EF know that a property is required).

關聯式資料表對應Relational Table mapping

可讓實體對應到資料表/資料行。Allows entities to be mapped to tables/columns.

索引鍵值產生Key value generation

包括用戶端產生與資料庫產生。Including client-side generation and database generation.

資料庫產生的值Database generated values

可讓值由資料庫在插入時產生 (預設值) 或在更新時產生 (計算資料行)。Allows for values to be generated by the database on insert (default values) or update (computed columns).

SQL Server 中的序列Sequences in SQL Server

可讓您在模型中定義序列物件。Allows for sequence objects to be defined in the model.

唯一的條件約束Unique constraints

可讓您定義替代索引鍵,並讓您定義以該索引鍵為目標的關聯性。Allows for the definition of alternate keys and the ability to define relationships that target that key.


在模型中定義索引會自動在資料庫中引進索引。Defining indexes in the model automatically introduces indexes in the database. 也支援唯一索引。Unique indexes are also supported.

陰影狀態屬性Shadow state properties

可讓您在未宣告且未儲存在 .NET 類別中但可由 EF Core 追蹤並更新的模型中定義屬性。Allows for properties to be defined in the model that are not declared and are not stored in the .NET class but can be tracked and updated by EF Core. 通常用於外部索引鍵屬性 (當不想要在物件中公開這些時)。Commonly used for foreign key properties when exposing these in the object is not desired.

每一階層資料表繼承模式Table-Per-Hierarchy inheritance pattern

可讓您使用鑑別子資料行來識別資料庫中指定資料列的實體類型,將繼承階層中的實體儲存到單一資料表。Allows entities in an inheritance hierarchy to be saved to a single table using a discriminator column to identify they entity type for a given record in the database.

模型驗證Model validation

偵測模型中的無效模式並提供實用的錯誤訊息。Detects invalid patterns in the model and provides helpful error messages.

變更追蹤Change tracking

快照集變更追蹤Snapshot change tracking

可讓您透過比較目前狀態與原始狀態的複本 (快照集),來自動偵測實體中的變更。Allows changes in entities to be detected automatically by comparing current state against a copy (snapshot) of the original state.

通知變更追蹤Notification change tracking

可讓您的實體在屬性值被修改時通知變更追蹤者。Allows your entities to notify the change tracker when property values are modified.

存取追蹤狀態Accessing tracked state

透過 DbContext.EntryDbContext.ChangeTrackerVia DbContext.Entry and DbContext.ChangeTracker.

附加取消附加的實體/圖表Attaching detached entities/graphs

新的 DbContext.AttachGraph API 有助於將實體重新附加到上下文,以減少使用新的/已修改的實體。The new DbContext.AttachGraph API helps re-attach entities to a context in order to save new/modified entities.

儲存資料Saving data

基本儲存功能Basic save functionality

可讓您將對實體執行個體所做的變更儲存到資料庫中。Allows changes to entity instances to be persisted to the database.

開放式並行存取Optimistic Concurrency

保護資料避免被使用者所進行的變更覆寫,因為資料是從資料庫所擷取的。Protects against overwriting changes made by another user since data was fetched from the database.

非同步儲存變更Async SaveChanges

在資料庫處理從 SaveChanges 發出的命令時,可以釋放目前的執行緒以處理其他要求。Can free up the current thread to process other requests while the database processes the commands issued from SaveChanges.

資料庫交易Database Transactions

表示 SaveChanges 一律都是不可部分完成 (表示它會完全成功,或不會對資料庫做任何變更)。Means that SaveChanges is always atomic (meaning it either completely succeeds, or no changes are made to the database). 也有交易相關 API 可在內容執行個體等之間共用交易。There are also transaction related APIs to allow sharing transactions between context instances etc.

關聯性:陳述式的批次處理Relational: Batching of statements

透過以批次方式在單一來回行程中對資料庫執行多個 INSERT/UPDATE/DELETE 命令。Provides better performance by batching up multiple INSERT/UPDATE/DELETE commands into a single roundtrip to the database.


基本 LINQ 支援Basic LINQ support

提供使用 LINQ 從資料庫擷取資料的功能。Provides the ability to use LINQ to retrieve data from the database.

混合用戶端/伺服器評估Mixed client/server evaluation

可讓查詢包含無法在資料庫中評估因而必須在資料擷取到記憶體之後評估的邏輯。Enables queries to contain logic that cannot be evaluated in the database, and must therefore be evaluated after the data is retrieved into memory.


查詢可讓您在上下文不需要監視對實體執行個體所做的變更 (亦即結果是唯讀的) 時有更快的查詢執行效能。Queries enables quicker query execution when the context does not need to monitor for changes to the entity instances (i.e. the results are read-only).

積極式載入Eager loading

提供 IncludeThenInclude 方法,以識別也應該在查詢時擷取的相關資料。Provides the Include and ThenInclude methods to identify related data that should also be fetched when querying.

非同步查詢Async query

在資料庫處理查詢時,可以釋放目前的執行緒 (與其關聯資源) 以處理其他要求。Can free up the current thread (and it's associated resources) to process other requests while the database processes the query.

原始 SQL 查詢Raw SQL queries

提供 DbSet.FromSql 方法,以使用原始 SQL 查詢來擷取資料。Provides the DbSet.FromSql method to use raw SQL queries to fetch data. 這些查詢也可以使用 LINQ 來撰寫。These queries can also be composed on using LINQ.

資料庫結構描述管理Database schema management

資料庫建立/刪除 APIDatabase creation/deletion APIs

大部分是針對您想要在不使用移轉的情況下快速建立/刪除資料庫的測試所設計。Are mostly designed for testing where you want to quickly create/delete the database without using migrations.

關聯式資料庫移轉Relational database migrations

可讓關聯式資料庫結構描述隨著您的模型變更而發展。Allow a relational database schema to evolve overtime as your model changes.

資料庫還原工程Reverse engineer from database

根據現有的關聯式資料庫結構描述架構 EF 模型。Scaffolds an EF model based on an existing relational database schema.

資料庫提供者Database providers

SQL ServerSQL Server

連線到 Microsoft SQL Server 2008 與更新的版本。Connects to Microsoft SQL Server 2008 onwards.


連線到 SQLite 3 資料庫。Connects to a SQLite 3 database.


設計為在不需要連線到實際資料庫的情況下輕鬆進行測試。Is designed to easily enable testing without connecting to a real database.

協力廠商提供者3rd party providers

有數個提供者提供其他資料庫引擎。Several providers are available for other database engines. 如需完整清單,請參閱資料庫提供者See Database Providers for a complete list.