SQLite EF 核心資料庫提供者的限制SQLite EF Core Database Provider Limitations

SQLite 提供者有幾項移轉限制。The SQLite provider has a number of migrations limitations. 大部分的這些限制是限制基礎 SQLite database engine 中的結果,並不專屬於 EF。Most of these limitations are a result of limitations in the underlying SQLite database engine and are not specific to EF.

模型限制Modeling limitations

通用的關聯式程式庫 (Entity Framework 關聯式資料庫提供者所共用) 會定義應用程式開發介面模型通用於大多數的關聯式資料庫引擎的概念。The common relational library (shared by Entity Framework relational database providers) defines APIs for modelling concepts that are common to most relational database engines. SQLite 提供者不支援幾個這些概念。A couple of these concepts are not supported by the SQLite provider.

  • 結構描述Schemas
  • 序列Sequences

移轉限制Migrations limitations

SQLite database engine 不支援大多數的其他關聯式資料庫所支援的結構描述作業的數目。The SQLite database engine does not support a number of schema operations that are supported by the majority of other relational databases. 如果您嘗試以不支援作業的其中一套用於 SQLite 資料庫則NotSupportedException就會擲回。If you attempt to apply one of the unsupported operations to a SQLite database then a NotSupportedException will be thrown.

運算Operation 支援?Supported? 需要版本Requires version
AddColumnAddColumn 1.01.0
CreateIndexCreateIndex 1.01.0
CreateTableCreateTable 1.01.0
DropIndexDropIndex 1.01.0
DropTableDropTable 1.01.0
RenameIndexRenameIndex 2.12.1
RenameTableRenameTable 1.01.0
EnsureSchemaEnsureSchema ✔ (無作業)✔ (no-op) 2.02.0
DropSchemaDropSchema ✔ (無作業)✔ (no-op) 2.02.0
InsertInsert 2.02.0
更新Update 2.02.0
刪除Delete 2.02.0

移轉限制因應措施Migrations limitations workaround

您可以解決一些手動中撰寫程式碼來執行資料表移轉這些限制的重建。You can workaround some of these limitations by manually writing code in your migrations to perform a table rebuild. 資料表重建牽涉到重新命名現有的資料表、 建立新的資料表、 將資料複製到新的資料表,以及卸除舊的資料表。A table rebuild involves renaming the existing table, creating a new table, copying data to the new table, and dropping the old table. 您必須使用Sql(string)方法,以執行這些步驟。You will need to use the Sql(string) method to perform some of these steps.

請參閱進行其他種類的資料表結構描述變更SQLite 文件以取得詳細資料中。See Making Other Kinds Of Table Schema Changes in the SQLite documentation for more details.

未來,EF 可能支援這些作業的某些使用背後的資料表重建方法。In the future, EF may support some of these operations by using the table rebuild approach under the covers. 您可以我們的 GitHub 專案上追蹤這項功能You can track this feature on our GitHub project.