相关疑难解决方法(0)

实体框架核心层级 ID

我正在尝试使用 EF Core,但我需要hierarchyid在我的一个表上使用 sql server 数据类型。

是否可以将我的 c# 类中的字段指定为hierarchyid 类型?

我可以在hierarchyid不破坏 EF 的情况下手动将列 EF 创建为类型吗?

编辑:我试图这样做:

public class Entity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public SqlHierarchyId HierarchyId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

建议 EF 核心 2.1 支持此功能,但是当我运行 add-migration 时,出现此错误:

The current CSharpHelper cannot scaffold literals of type 'Microsoft.SqlServer.Types.SqlHierarchyId'. Configure your services to use one that can.
Run Code Online (Sandbox Code Playgroud)

entity-framework entity-framework-core

9
推荐指数
2
解决办法
6081
查看次数