将.NET布尔数据类型映射到实体框架中的oracle编号(1,0)会引发错误如何解决?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (29)

将.NET布尔数据类型映射到.edmx文件中的oracle编号(1,0)会引发以下错误。

Error 2019: Member Mapping specified is not valid. The type 'Edm.Boolean[Nullable=False,DefaultValue=]' of member 'COLUMN123' in type 'DBModel.TABLE123' is not compatible with 'OracleEFProvider.number[Nullable=False,DefaultValue=,Precision=1,Scale=0]' of member 'CHECK_INSTALLATION' in type 'DBModel.Store.TABLE123'.

可以使用实体框架将布尔数据类型映射到Oracle的编号(1,0)?

提问于
用户回答回答于

下面是包含一个自定义映射的app.config示例,其中NUMBER(1,0)映射到Bool,NUMBER(3,0)映射到Byte,Int16,Int32和Int64的最大精度更改为4 ,9,18分别默认值为5,10,19,分别为:

         <?xml version="1.0" encoding="utf-8"?>
         <configuration>
         <connectionStrings>
         </connectionStrings>
         <oracle.dataaccess.client>
         <settings>
         <add name="bool" value="edmmapping number(1,0)" />
         <add name="byte" value="edmmapping number(3,0)" />
         <add name="int16" value="edmmapping number(4,0)" />
         <add name="int32" value="edmmapping number(9,0)" />
         <add name="int64" value="edmmapping number(18,0)" />
         </settings>
         </oracle.dataaccess.client>
         </configuration>

以同样的方式,可以将.net bool映射到Oracle Number(1,0)

用户回答回答于

添加一个oracle.dataaccess.client部分对我来说是不够的。以下确实有效:

<configuration>
  <configSections>
    <section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
...
<oracle.dataaccess.client>
  <settings>
    <add name="bool" value="edmmapping number(1,0)" />
  </settings>
</oracle.dataaccess.client>
<oracle.manageddataaccess.client>
  <version number="*">
    <edmMappings>
      <edmMapping dataType="number">
        <add name="bool" precision="1"/>
        <add name="byte" precision="2" />
        <add name="int16" precision="5" />
      </edmMapping>
    </edmMappings>
  </version>
</oracle.manageddataaccess.client>

扫码关注云+社区