实体框架核心SQLite版本

时间:2019-02-15 11:06:38

标签: entity-framework-core

我正在将EF Core v2.2.1用于SQLite,并进行了新的迁移,在其中我重命名了表中的字段。

迁移代码如下

migrationBuilder.RenameColumn(
    name: "OldColumnName",
    table: "Table",
    newName: "NewColumnName");

当我应用迁移时,它将创建以下SQL:

ALTER TABLE "Table" RENAME COLUMN "OldColumnName" TO "NewColumnName";

使用SQLite 3.25观看它受支持https://www.sqlite.org/changes.html

Enhancements the ALTER TABLE command:

    Add support for renaming columns within a table using ALTER TABLE table RENAME COLUMN oldname TO newname.
    Fix table rename feature so that it also updates references to the renamed table in triggers and views.

但是在EF Core中,我收到一个例外:

Error while executing SQL query on database 'MyDatabase': near "COLUMN": syntax error

听起来像是使用旧版本的SQLite。如何检查EF Core使用哪个版本?

编辑:我找到了一种解决方法,但实际上我的问题是“我如何知道我当前正在使用哪个版本的SQLite?”。

1 个答案:

答案 0 :(得分:1)

在ef core中为sqlite db重命名一列是受限制的,不支持您可以找到官方限制列表here

有关于此问题的错误报告,您可以找到它here
here

中有针对此问题的解决方法