【发布时间】:2020-06-18 15:44:29
【问题描述】:
我正在试验 .net 核心、实体框架和 sqlserver,我认为 hierarchyID 是我尝试建模的完美数据类型。但是当我搭建数据库时,EFC 无法映射层次结构。
Could not find type mapping for column 'dbo.ingredient.hierarchy_id' with data type 'hierarchyid'. Skipping column.
Could not scaffold the primary key for 'dbo.ingredient'. The following columns in the primary key could not be scaffolded: hierarchy_id.
Unable to generate entity type for table 'dbo.ingredient'.
Could not find type mapping for column 'dbo.ingredient_location.ingredient_id' with data type 'hierarchyid'. Skipping column.
Could not find type mapping for column 'dbo.locations.location' with data type 'geography'. Skipping column.
Could not find type mapping for column 'dbo.pantry_ingredient.ingredient_id' with data type 'hierarchyid'. Skipping column.
我应该放弃使用该数据类型的想法还是有解决方法?
我寻找了一些解决方案,但它们都需要手工编写脚手架,我目前没有足够的信心这样做
【问题讨论】:
-
hierarchyid 似乎没有得到 EF Core 的良好支持。有关一些提示,请参阅 SO 问题和答案Entity Framework Core hierarchyid。
-
感谢您的回复,我决定通过定义父 id 字段来使用自定义层次结构
标签: .net sql-server entity-framework scaffolding hierarchyid