EF Core是什么
EF Core 是一個 O/RM(Object Relational Mapping)對象關系映射 框架,它也提供了對數據增刪改查的基礎封裝,提供了Code First 的開發,它也有批量增刪的功能擴展;
EF特征
- 支持多種數據庫 MSSQL ,MySQL,SQLite,InMemory
- 支持數據庫的逆向工程,可以先建立模型也可以先建立數據庫
- 更改模型后可以使用遷移來更新數據庫架構
- 輕量級的, 開源的, 可擴展的,支持跨平台的
- 使用簡易,使用的人多,能夠提高生產效率
- 可以使用Linq
- 注重領域,而不是數據庫
EF Core VS EF6
相同點
- DBContext&DBSet
- Data Model
- Querying using Linq-to-Entities
- Change Tracking
- SaveChanges
- Migrations
EF6 獨有 (表示懷疑)
- EDMX/ Graphical Visualization of Model
- Entity Data Model Wizard (for DB-First approach)
- ObjectContext API
- Querying using Entity SQL.
- Automated Migration
- Inheritance: Table per type (TPT)
- Inheritance: Table per concrete class (TPC)
- Many-to-Many without join entity
- Entity Splitting
- Spatial Data
- Lazy loading of related data
- Stored procedure mapping with DbContext for CUD operation
- Seed data 這個現在有了啊??
- Automatic migration
EF Core獨有
- Easy relationship configuration 簡易的關系配置
- Batch INSERT, UPDATE, and DELETE operations 批量操作
- In-memory provider for testing 不干擾測試數據庫
- Support for IoC (Inversion of Control) 支持依賴控制
- Unique constraints 唯一鍵的約束
- Shadow properties 影子屬性
- Alternate keys 備用鍵
- Global query filter 全局查詢過濾
- Field mapping 字段映射
- DbContext pooling DbContext池
- Better patterns for handling disconnected entity graphs 更好的方式處理斷開實體圖