2
votes

I have an existing Oracle 11g database.

I create a new solution and a new project (.net 4.5) to which I add the following NuGet packages:

  • package id="EntityFramework" version="6.1.3"
  • package id="Oracle.ManagedDataAccess" version="12.1.24160419"
  • package id="Oracle.ManagedDataAccess.EntityFramework" version="12.1.2400"

My web.config specifies a section for the edmMappings.

<oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) " />
      </dataSources>

      <edmMappings>
        <edmMapping dataType="number">
          <add name="int64" precision="10" />
        </edmMapping>
      </edmMappings>
    </version>
</oracle.manageddataaccess.client>

I then add a new ADO.NET Entity Data Model using EF Designer from databse (model first).

I have a table PROCESS with a LINK_ID column that is defined as NUMBER (10) in Oracle.

The generated .edmx files and entites (generated through the tt file) use a normal int (Int32) rather than a long (Int64) as specified in my mapping.

I would like for the generated model to use a long.

I can go and change this manually, but then I get the following error at run time:

Schema specified is not valid. Errors: \r\nTestMappings2.msl(18,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.Int64[Nullable=True,DefaultValue=]' of member 'LINK_ID' in type 'Model.PROCESS' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=10,Scale=0]' of member 'LINK_ID' in type 'Model.Store.PROCESS'.

How can I make the generated model use the correct type and why does changing the type give me a runtime mapping error?

1
I did not include my full .config file since it the connection to Oracle itself seems to be working if I do not include the NUMBER(10) column but I can post it if someone is interested. - Lastwall

1 Answers

3
votes

From docs.oracle.com it appears edmMappings syntax has changed to specify Min and Max precision instead of specifying cut-off points.

<add NETType="int64" MinPrecision="10" MaxPrecision="19" DBType="Number" />

The old syntax would be:

<add name="int32" precision="9" />
<add name="int64" precision="18" />