18
votes

Mapping .NET boolean datatype to oracle number(1,0) in .edmx file throws following error.

Error 2019: Member Mapping specified is not valid. The type 'Edm.Boolean[Nullable=False,DefaultValue=]' of member 'COLUMN123' in type 'DBModel.TABLE123' is not compatible with 'OracleEFProvider.number[Nullable=False,DefaultValue=,Precision=1,Scale=0]' of member 'CHECK_INSTALLATION' in type 'DBModel.Store.TABLE123'.

Can a Boolean datatype be mapped to oracle's number(1,0) using entity framework?

5
What version of the Oracle Provider are you using? There is a long thread in ODN (forums.oracle.com/forums/…) where people discuss similar problems with various betas, problems with stale assembly.congif files etc, that are solved in the final versionPanagiotis Kanavos
Adding the following setting to my application configuration file removes the compile time error and the application runs perfectly fine. <oracle.dataaccess.client> <settings> <add name="bool" value="edmmapping number(1,0)" /> </settings> </oracle.dataaccess.client> However the Visual Studio still sometimes shows this error when I open my .edmx file as soon as I close the .edmx file the error is gone.surajnaik
And it seems the need for the extra mapping hasn't been fixed in the final release. BTW I noticed the previous link doesn't work, people should try this link forums.oracle.com/forums/thread.jspa?threadID=2308263. As for the VS error there isn't much you can do about it. There seems to be a bug in the error list that causes old error messages to appear even after they have been fixed. A full compile usually clears them. This is not EDMX specific, I encounter this problem all the time.Panagiotis Kanavos

5 Answers

9
votes

Adding a oracle.dataaccess.client section wasn't sufficient for me. The following (taken from Deploying and Configuring ODP.NET to work without installation with Entity Framework) did work:

<configuration>
  <configSections>
    <section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
...
<oracle.dataaccess.client>
  <settings>
    <add name="bool" value="edmmapping number(1,0)" />
  </settings>
</oracle.dataaccess.client>
<oracle.manageddataaccess.client>
  <version number="*">
    <edmMappings>
      <edmMapping dataType="number">
        <add name="bool" precision="1"/>
        <add name="byte" precision="2" />
        <add name="int16" precision="5" />
      </edmMapping>
    </edmMappings>
  </version>
</oracle.manageddataaccess.client>
3
votes

Was getting this error in VS 2015. The project would compile without errors, but error list would still show this error. Added the following section to my app.config to resolve the issue. Please note that edmMapping element is not compatible with the XSD schema that oracle provides (so you get a warning about it if your config file is open), but it's still better than having those errors show up.

    <oracle.manageddataaccess.client>
    <version number="*">
        <edmMappings>
            <edmNumberMapping>
                <add NETType="bool" MinPrecision="1" MaxPrecision="1" DBType="Number" />
            </edmNumberMapping>
            <edmMapping dataType="number">
                <add name="bool" precision="1"/>
            </edmMapping>
        </edmMappings>
    </version>
</oracle.manageddataaccess.client>
1
votes

Below is an example of app.config that contains a custom mapping where NUMBER(1, 0) is mapped to Bool, NUMBER(3,0) is mapped to Byte, and the maximum precisions for Int16, Int32, Int64 are changed to 4, 9, 18 from the default values of 5, 10, 19, respectively:

         <?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)" />
         <add name="int32" value="edmmapping number(9,0)" />
         <add name="int64" value="edmmapping number(18,0)" />
         </settings>
         </oracle.dataaccess.client>
         </configuration>

In the same way you can map .net bool to Oracle Number(1,0)

1
votes

This configuration worked for me using VS 2012, EF5 with Oracle 11 and oraclManageDataAccess 12.1. NUMBER 1 not null was converted to bit.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework"
             type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
             requirePermission="false" />
  </configSections>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  <connectionStrings>
  </connectionStrings>
  <oracle.manageddataaccess.client>
    <version number="*">
      <edmMappings>
        <edmMapping dataType="number">
          <add name="bool" precision="1" />
          <add name="byte" precision="2" />
          <add name="int16" precision="5" />
        </edmMapping>
      </edmMappings>
    </version>
  </oracle.manageddataaccess.client>
</configuration>
0
votes

I got the errors when I copied a solution to use for a new project, so I changed from the unmanaged oracle driver to the managed oracle driver, then the problem went away, but when I published to the server, the server did not have the managed oracle driver installed, so I had to change back to the unmanaged oracle driver. Problem came back of course, so I went to the server explorer and verified that I could connect to my oracle sources (using the unmanaged driver), then I opened the edmx file and right clicked and clicked validate which still showed the errors on the error list, then I simply right clicked and clicked update model from database, verified that the tables were listed in the refresh tab, then clicked finish, it took a little while for the update to finish, but when it was done the errors went away.

I believe this error comes up when trying to use the unmanaged driver settings in the web.config and app.config files but connecting to the managed driver in the server explorer (which is the connection that the edmx 'update model from database' action uses), or vise versa.