Entity Framework with Oracle - Edmmapping

c# entity-framework-6 oracle


I'm working with the Entity Framework 6 on an Oracle legacy database. The EF maps for example Number(1) automatically to bool or Number(2) to byte, but I need to have them all as Int32.

I have added the edmMappings block to the app.config like described by Oracle: https://docs.oracle.com/cd/E56485_01/win.121/e55744/entityDataTypeMapping.htm#BABGBJCI But it doesn't work, it always generates bool and int16 instead of int32

My Mapping in the app.config:

    <version number="*">
          <add NETType="int32" MinPrecision="1" MaxPrecision="1" DBType="Number" />
          <add NETType="int32" MinPrecision="2" MaxPrecision="3" DBType="Number" />
          <add NETType="int32" MinPrecision="4" MaxPrecision="5" DBType="Number" />
          <add NETType="int32" MinPrecision="6" MaxPrecision="10" DBType="Number" />
          <add NETType="int64" MinPrecision="11" MaxPrecision="19" DBType="Number" />
        <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) " />

I tried different things in this block, but nothing changes. Is there something else I need to configure?

2/3/2016 9:42:49 AM

Popular Answer

In case you didn't do this already: in addition to the edmMappings I think you have to change the type of your properties in your model entities as well. E.g. in Visual Studio, open the model diagram (*.edmx) right click the property with type Number(X) in your database, open Properties and change 'Type' to the type you want.

7/11/2018 10:27:17 AM

Related Questions


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