Oracle
 sql >> Database >  >> RDS >> Oracle

Da Oracle DB a EF non funziona correttamente per NUMBER(2,0)

La colonna del database Oracle per un Int32 .Net dovrebbe essere:NUMBER(9, 0)

Secondo la Tabella di conversione :

+------------------------------+------------------+-----------------+
|         Oracle Type          | Default EDM Type | Custom EDM Type |
+------------------------------+------------------+-----------------+
| Number(1,0)                  | Int16            | bool            |
| Number(2,0) to Number(3,0)   | Int16            | byte            |
| Number(4,0)                  | Int16            | Int16           |
| Number(5,0)                  | Int16            | Int32           |
| Number(6,0) to Number(9,0)   | Int32            | Int32           |
| Number(10,0)                 | Int32            | Int64           |
| Number(11,0) to Number(18,0) | Int64            | Int64           |
| Number(19,0)                 | Int64            | Decimal         |
+------------------------------+------------------+-----------------+

Modifica:

Ho trovato un modo per forzare il Number(2,0) da tradurre in un byte in App.Config per l'approccio Database-First :

<?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)" />

RIF:https://docs.oracle.com/database/121 /ODPNT/entityDataTypeMapping.htm#ODPNT8300