ODP.NET 12c problems with Oracle 11g

c# entity-framework-6 odp.net oracle

Question

I'm developing an Entity Framework application using Oracle 12c and ODP.NET Managed Drivers 12c with Entity Framework 6.

All the application is working fine in Oracle 12c version, but we have a customer wich uses Oracle 11g version. In this customer I am having the bellow issue when storing a number(8) value in 11g database:

A store-generated value of type 'System.Int32' could not be converted to a value of type 'System.Int16' required for member 'ALARMID' of type 'Model.ALARMS'.

I tried editing my model mannualy setting my AlarmID field to Int32 (current is Int16) and this error stops, but the value stored in the database becomes a negative value. Going back to Int16 the problem above persists.

I searched Oracle forums but nothing that answers me this question.

Do somebody had this king of problem?

Thanks

1
1
5/19/2017 7:07:50 PM

Popular Answer

Well, problem solved!

I updated the ODP.NET Managed Driver in the Nuget packages and was able to enter the new EDM Mappings for my fields.

In my app.config I added this line:

  <oracle.manageddataaccess.client>
    <version number="*">
      <edmMappings>
        <edmNumberMapping>
          <add NETType="int16" MinPrecision="1" MaxPrecision="4" DBType="Number" />
        </edmNumberMapping>
      </edmMappings>
    </version>
  </oracle.manageddataaccess.client>

This solved the cast error in both Oracle Versions.

About this:

I tried editing my model mannualy setting my AlarmID field to Int32 (current is Int16) and this error stops, but the value stored in the database becomes a negative value. Going back to Int16 the problem above persists.

It was a mistaken cast I was doing in my code. My bad!

0
5/23/2017 12:58:17 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow