oracleasp.net-mvc-5entityodp.net

Entity Framework with EF6 Runtime Exception 'Member Mapping specified is not valid'


I have just migrated to EF6 and here is what is happening. I have done everything suggested in any post on stackoverflow or oracle so I decided to open another question.

1) My Model is in a separated assembly. 2) I have done everything that I was supposed to do to regenerate my Model (deleted the .tt files and refresh my model from DB). 3) After doing that, the new EF seems to be too smart and decided to create all my number(1) fields as boolean. 4) this would cause an enormous rework for me. 5) I decided to added the following entries to web.config in the solution where I have the Model.

  <oracle.dataaccess.client>
    <settings>
      <add name="int16" value="edmmapping number(1,0)" />
      <add name="int16" value="edmmapping number(3,0)" />
      <add name="int16" value="edmmapping number(4,0)" />
      <add name="int32" value="edmmapping number(9,0)" />
      <add name="int64" value="edmmapping number(18,0)" />
    </settings>
  </oracle.dataaccess.client>

I refreshed my model and everything was fine. 6) When I run the app that has reference to my Model Assembly, i get the following exception when opening my connection to the Oracle Database.

error 2019: Member Mapping specified is not valid. The type 'Edm.Int16[Nullable=True,DefaultValue=]' of member 'TRACKATTENDANCEFLAG' in type 'Model.FACILITY' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=1,Scale=0]' of member 'TRACKATTENDANCEFLAG' in type 'Model.Store.FACILITY'.

7) I have added the same entries in the application that uses the Model but it does not matter, I keep getting the same exception.

8) I'm not using the Managed Drive. I'm using the Oracle.DataAccess.Client.

9) Oracle.DataAccess.Client version 2.121.2.0 Oracle.DataAccess.EntityFramework version 6.121.2.0

Does anyone have any ideas? I spent more than 20 hours trying to figure out. I have tried all possible combinations. It is so freaking wrong that Oracle would let me generate my Model but failed during runtime against the exact database.

I appreciate any help


Solution

  • Had the same issue and tried all solutions I've found. The only one that worked was adding the following code to all my Web.config and app.config files under the <connectionStrings></connectionStrings>.

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

    My setup is: