18

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?

4
  • 1
    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 version Commented Feb 1, 2012 at 12:28
  • 3
    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. Commented Feb 9, 2012 at 7:28
  • 2
    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. Commented Feb 9, 2012 at 8:58
  • possible duplicate of EF EDM Builder Oracle Number(1, 0) -> Int16/Bool Commented Oct 26, 2013 at 17:21

5 Answers 5

9

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>
Sign up to request clarification or add additional context in comments.

3 Comments

This worked perfectly for me when I wanted to build -- but did notice that with that in the .config, EF wouldn't let me update the EDM Designer any more. It'd think I had an incompatible data provider. Removing the chunk let me edit in Designer mode again. So odd.
Also, I could clean the solution, build the project directly with no errors, then build the solution - no problems. If I cleaned and built the solution, the EF project would bark at me. I either have to remember to recomment/uncomment the .config or build the EF project before the rest of the solution.
Same as Jason. I think it's because of a bug with Visual Studio's error list at the point because the project builds fine but depending if I build the solution or the project the errors get shown or not.
4

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>

3 Comments

now with Oracle.ManagedDataAccess you don't need anything
@Toolkit, Actually I still have the errors pop up at design time with Oracle.ManagedDataAccess v4.122.1.0
@BasselShmali i suggest you do a clean test project, install the latest version of Oracle.ManagedDataAccess and try
1

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)

Comments

1

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>

1 Comment

I only added the config Settings to the Project where I was having my EF5 model. While compiling this Project there were no Errors, I got plenty of errors while compiling other projects in the same solution. I found out, that I had to copy the app.config into every project that was linked to the EF5 model project to get rid of the compilier errors. I was using VS 2012 with Oracle Managed Data Access 12.1 last release from December.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.