【问题标题】:Member Mapping specified is not valid.Error in ADO.net Entity Framework when add new column in database?指定的成员映射无效。在数据库中添加新列时 ADO.net 实体框架中的错误?
【发布时间】:2025-12-09 14:35:01
【问题描述】:

我对@9​​87654322@ 框架非常陌生,我收到以下错误

 The type 'Edm.Byte' of the member 'IsActive' in the conceptual side type 
 NopSolutions.NopCommerce.BusinessLogic.Data.Language' does not match with the type 
 System.Boolean' of the member 'IsActive' on the object side type   NopSolutions.NopCommerce.BusinessLogic.Directory.Language'.

据我了解,在关联 edmobject 的数据类型方面存在一些缺失/p>

但我在数据库表中创建了一个位类型的列,并在langauge.cs 中声明了

   public bool IsActive { get; set; }

我可以在这里发布任何需要的细节

编辑:

当我在 Google 上搜索时,我在 * 上发现了这个问题

et-model-property-to-boolean-in-entity-framework 将 Byte 更改为 Boolean 以映射 tinyint

但在我的情况下,我在数据库中也有一点。

【问题讨论】:

    标签: entity-framework ado.net nopcommerce


    【解决方案1】:

    假设您有一个可以修改的 .edmx 文件。在 XML 编辑器中打开它并搜索 <edmx:ConceptualModels>-元素。这应该包含您的实体的定义,查找<EntityType Name="Language">-元素,它应该声明如下内容:

    <Property Name="IsActive" Type="Byte" Nullable="false" />
    

    Type-属性更改为Boolean

    我很确定您也可以在设计器中执行此操作,但如果您无法直接访问 .edmx,请告诉我,我们会想办法。

    【讨论】:

    • @Tihon 感谢好友的作品。我拥有 .edmx 文件的权限,因此右键单击字段并将其数据类型更改为布尔值
    • 更新 EDMX 不能解决这个问题吗?
    最近更新 更多