3

I'm using EF6 ModelFirst and Oracle ODP Managed driver 12c to develop .NET application (One solution containing solely one project)

I run into a mapping problem between Oracle and .NET.

I'm trying to specify custom mapping in web.config like that :

<oracle.manageddataaccess.client>
 <version number="*">
  <edmMappings>
    <edmMapping dataType="number">
      <add name="bool" precision="1" />
      <add name="byte" precision="3" />
      <add name="int16" precision="4" />
      <add name="int32" precision="9" />
      <add name="int64" precision="18" />
    </edmMapping>
  </edmMappings>
  <dataSources>
    ...
  </dataSources>
 </version>
</oracle.manageddataaccess.client>

After generating the .edmx, number(5) columns are still mapped into "short" .NET Type (Int16)

Obviously, this .NET Type is not suitable for ZIP code like 59000

If I modify the column mapping from Int16 to Int32 Type in the .edmx, I get the 2019 error specifying that I've got bad mapping

Workaround: When I modify the xml version of the edmx, if I delete the precision of the column it works with Int32 but after updating the model from database, the modifications are overwritten.

Gilles
  • 5,269
  • 4
  • 34
  • 66
  • http://stackoverflow.com/questions/13721025/deploying-and-configuring-odp-net-to-work-without-installation-with-entity-frame – Chobits Mar 23 '16 at 06:48
  • Just a note that the link to stackoverflow.com/questions/13721025/ was written before the changes to EF 6 and will not work as is in EF 6. – Gilles Dec 08 '16 at 15:23

1 Answers1

3

The edmMappings syntax has changed with EF 6.

You must now use the following syntax:

<oracle.manageddataaccess.client>
    <version number="*">  
      <edmMappings>
        <edmNumberMapping>
          <add NETType="bool" MinPrecision="1" MaxPrecision="1" DBType="Number" />
          <add NETType="byte" MinPrecision="2" MaxPrecision="3" DBType="Number" />
          <add NETType="int16" MinPrecision="4" MaxPrecision="4" DBType="Number" />
          <add NETType="int32" MinPrecision="5" MaxPrecision="9" DBType="Number" />
          <add NETType="int64" MinPrecision="10" MaxPrecision="18" DBType="Number" />
        </edmNumberMapping>  
      </edmMappings>      
    </version>
  </oracle.manageddataaccess.client>

You now need to specify the DBType on every line rather than as an attribute to the mapping section.

You also use NETType rather than name.

And finally you must define a min and max precision.

Documentation link: Oracle Number Default Data Type Mapping and Customization Under section Entity Framework 6 Mapping and Customization

Gilles
  • 5,269
  • 4
  • 34
  • 66