SQL Server EF 核心資料庫提供者的記憶體最佳化資料表支援Memory-Optimized Tables support in SQL Server EF Core Database Provider


在 EF 核心 1.1 已引入此功能。This feature was introduced in EF Core 1.1.

記憶體最佳化資料表是整個資料表在記憶體中的所在位置的 SQL Server 的功能。Memory-Optimized Tables are a feature of SQL Server where the entire table resides in memory. 資料表資料的第二個副本保留在磁碟上,但僅做為持久性用途。A second copy of the table data is maintained on disk, but only for durability purposes. 記憶體最佳化資料表中的資料只會在資料庫復原時從磁碟中讀取。Data in memory-optimized tables is only read from disk during database recovery. 例如,伺服器重新啟動後。For example, after a server restart.

設定記憶體最佳化資料表Configuring a memory-optimized table

您可以指定實體對應到資料表是記憶體最佳化。You can specify that the table an entity is mapped to is memory-optimized. 當使用來建立並維護資料庫的 EF Core 根據您的模型 (不論是透過移轉或Database.EnsureCreated()),記憶體最佳化資料表將會建立針對這些實體。When using EF Core to create and maintain a database based on your model (either with migrations or Database.EnsureCreated()), a memory-optimized table will be created for these entities.

protected override void OnModelCreating(ModelBuilder modelBuilder)