This discussion is archived
1 2 Previous Next 20 Replies Latest reply: Dec 5, 2012 3:16 AM by 972836 RSS

BUG: Number(1,0) to Boolean System.Data.MappingException with ODAC v112030

DNETFX Newbie
Currently Being Moderated
I am using ODAC release version 112030.

I mapped a nullable boolean property to a nullable number(1,0) column (database first).
Validation of edmx passes without errors or warnings.

My App.Config contains the following section:

<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(5,0)" />
<add name="int32" value="edmmapping number(10,0)" />
<add name="int64" value="edmmapping number(19,0)" />
<add name="int16" value="edmmapping number(38,0)" />
<add name="int32" value="edmmapping number(38,0)" />
<add name="int64" value="edmmapping number(38,0)" />
</settings>
</oracle.dataaccess.client>

Where I added the last 3 lines as a workaround for unspecified precision in a legacy schema.

If I remove the boolean property the code runs as expected.
Is I add the boolean property (mapped to a number(1,0) column), when the first query runs, I received the following exception:

Type: System.Data.MappingException

Message:
Schema specified is not valid. Errors:
Nre.msl(82,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.Boolean[Nullable=True,DefaultValue=]' of member 'IsImported' in type 'Model.EntityType1' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=1,Scale=0]' of member 'IMPORTED' in type 'Model.Store.TABLE_1'.
  • 1. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    15208 Explorer
    Currently Being Moderated
    Did you use the custom type mapping specified in your App.Config to generate your data model?
    The CSDL file or the CSDL section/content of the edmx file should show number(1, 0) columns are mapped to Boolean type.
  • 2. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    DNETFX Newbie
    Currently Being Moderated
    SSDL:

    <Property Name="IMPORTED" Type="number" Precision="1" />

    CSDL:

    <Property Type="Boolean" Name="IsImported" Nullable="false" />

    C-S mapping:

    <ScalarProperty Name="IsImported" ColumnName="IMPORTED" />


    I created the EDMX prior to adding section to App.Config.

    Edited by: 898264 on Feb 1, 2012 5:15 AM
  • 3. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    15208 Explorer
    Currently Being Moderated
    Thanks for the confirmation.
    Your Entity Data Model was not generated with your custom type mapping.
    You may want to remove the entry in <connectionStrings> and regenerate the model with current App.Config.
    Then you should not have such issue.

    By the way, your custom type mapping seems questionable. I think essentially you will get the following mapping.

    <add name="bool" value="edmmapping number(1,0)" />
    <add name="byte" value="edmmapping number(3,0)" />
    <add name="int16" value="edmmapping number(5,0)" />
    <add name="int32" value="edmmapping number(10,0)" />
    <add name="int64" value="edmmapping number(19,0)" />

    The above last thress are same as default mapping.

    The following three will be ignored.
    <add name="int16" value="edmmapping number(38,0)" />
    <add name="int32" value="edmmapping number(38,0)" />
    <add name="int64" value="edmmapping number(38,0)" />

    Edited by: shsu on Feb 1, 2012 1:49 PM
  • 4. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    DNETFX Newbie
    Currently Being Moderated
    Hi shsu,

    Regarding the exception:

    I assume you mean that the EDMX was not created after the App.Config changes, which is correct.

    The model is created with customized POCO T4s and has been recreated.

    How can I update the EDMX manually without recreating it? (What xml changes are required?)


    Regarding the mappings:

    Does <add name="int32" value="edmmapping number(10,0)" /> mean enabling mapping numbers of precision 1 and above to bool?
    If so, I agree, the last three lines are redundant.

    However, if these lines
    <add name="int32" value="edmmapping number(10,0)" />
    <add name="int64" value="edmmapping number(19,0)" />
    mean map 10-18 to int32 and 19+ to int64, then I still need the last three lines.

    Thanks.
  • 5. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    15208 Explorer
    Currently Being Moderated
    The mapping is using "range". The precision indicates the upper limit for the type.

    Below is the list of default mapping:
         
         Oracle Type      .NET/EDM type
    =============      =============
         number(1, 0)      Int16
         number(2, 0)      Int16
         number(3, 0)      Int16
         number(4, 0)      Int16
         number(5, 0)      Int16

         number(6, 0)      Int32
         number(7, 0)      Int32
         number(8, 0)      Int32
         number(9, 0)      Int32
         number(10, 0)      Int32

         number(11, 0)      Int64
         number(12, 0)      Int64
         number(13, 0)      Int64
         number(14, 0)      Int64
         number(15, 0)      Int64
         number(16, 0)      Int64
         number(17, 0)      Int64
         number(18, 0)      Int64
         number(19, 0)      Int64
         
         number(p, s) Decimal (where p > 19 and/or s is not 0)

    Examples:

    When you have mapped number(1, 0) to Boolean, Int16 mapping range becomes from number(2, 0) to number(5, 0).

    When you have mapped number(4, 0) to Int16, Int16 mapping range becomes from number(2, 0) to number(4, 0).
    Int32 mapping range becomes from number(5, 0) to number(10, 0) and Int64 is from number(11, 0) to number(19, 0).

    When you have mapped number(9, 0) to Int32, Int32 mapping range is from number(5, 0) to number(9, 0) and
    Int64 mapping range is from number(10, 0) to number(19, 0).


    Regarding "update the EDMX", you may try "Table Mapping" without manually update it.
    In your class for the POCO entity, the attribte type should match.

    (I removed the restriction I mentioned previously. It's seems the restriction has been lifted.)

    Edited by: shsu on Feb 2, 2012 12:29 PM
  • 6. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    DNETFX Newbie
    Currently Being Moderated
    Even though doing so makes no sense to me, I tried creating another EDMX (after app.config already contained custom type mappings).

    The new EDMX did not differ from the old one - the problem is not in the EDMX.

    This and the fact that the EDMX passes validation and the exception is only received at run time makes me suspect that there is a bug in the ODP.NET assembly.

    Does Oracle's support not answer posts?
  • 7. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated
    On another thread, shsu posted a more detailed explanation of the Error 2019 issue:
    Superfluous Error 2019 still there

    Scroll to near the bottom.

    Edited by: Alex Keh - Oracle Product Manager on Feb 8, 2012 5:44 PM
  • 8. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    DNETFX Newbie
    Currently Being Moderated
    Thanks for the reply, I thought that Oracle employees are supposed to have an ace shaped icon.

    I tried the following:

    1. Explicitly referenced the correct version/platform of Oracle.DataAccess.dll (even though I uninstalled the beta3 prior to installing the release).
    2. Deleted the connection string from App.Config
    3. Deleted the EDMX
    4. Recreated the EDMX
    5. Redid all my data type settings (replacing decimal with int32 or int16)
    6. Renamed all the classes and properties again
    7. Reran template generation
    8. Rebuilt
    9. Ran test

    yet the EDMX still passes validation and I still get the same exception.
    (After deleting all boolean properties, running generation, building and running test test passes.)

    You can see from the xml sections I previously posted that the definitions and mappings look OK.
    If they weren't the validation would fail e.g. when I intentionally change the boolean property's type to Guid I receive the following error during VALIDATION:

    Error 2019: Member Mapping specified is not valid. The type 'Edm.Guid[Nullable=True,DefaultValue=]' of member 'IsImported' in type 'MyClass' is not compatible with 'OracleEFProvider.number[Nullable=True,DefaultValue=,Precision=1,Scale=0]' of member 'IMPORTED' in type 'MyTable'.

    Whereas when the type matches validation passes and I receive Error 2019 during RUNTIME.

    Is there anything else I can try?

    Thanks.
  • 9. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    DNETFX Newbie
    Currently Being Moderated
    I found the cause of the exception.

    Since the validation passes, but the mapping fails at run time, I figured out it is probably an issue of the ODP.NET reading the wrong app.config file.

    I copied the mapping section from the assembly that contains the EDMX and EF context to the test assembly and then ran the tests again.

    This fixed the issue._

    Could ODP.NET be updated so it can access the EDMX's assembly's app.config and not only the application?

    Maintaining these mappings at the application level can cause conflicts if the application has more than one EDMX with different mappings and also requires all applications that consume the library to define internal settings.

    Thanks.
  • 10. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    Tridus Journeyer
    Currently Being Moderated
    Probably not, since that's a .net thing. After you build the project, the application's app.config (or web.config) is the only one that actually gets included. It doesn't bring in the config files of every imported assembly.
  • 11. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    DNETFX Newbie
    Currently Being Moderated
    Actually, .NET does support a config file per assembly (renamed to <YourAssemblyName>.config).
  • 12. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    Tridus Journeyer
    Currently Being Moderated
    Oh cool. Learned something today. :)
  • 13. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    15208 Explorer
    Currently Being Moderated
    Thanks for sharing the solution.

    Looks like your case is a solution file with multiple projects for Context, Model, and Application (or Test).

    Because the Application project is the active (Startup) project. At runtime ODP.NET reads the App.Config of the Application project. But this App.Config only has the connection string and no custom type mapping section, therefore type mapping issue arises.

    The custom type mapping section is only in the App.Config for the Context project. Your solution is to copy the custom type mapping section to the App.Config for the Application project.
  • 14. Re: Number(1,0) to Boolean System.Data.MappingException with ODAC ver 112030
    DNETFX Newbie
    Currently Being Moderated
    For future reference, this is how to get rid of the warning due to the additions to the app.config section..._

    Add an xsd to the projects with the Oracle app.config section and define that the app.config uses it (open app.config, go to properties window and add your xsd to the list of schemas).

    This is the .xsd I created for my own usage (might not be accurate, since I haven't read Oracle's app.config spec!):

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema id="odpnetappconfigmappings" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:complexType name="addtype">
    <xs:attribute name="name" type="xs:string" />
    <xs:attribute name="value" type="xs:string" />
    </xs:complexType>

    <xs:complexType name="settingstype">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element name="add" type="addtype" />
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="oracledataaccessclienttype">
    <xs:sequence minOccurs="0" maxOccurs="1">
    <xs:element name="settings" type="settingstype" />
    </xs:sequence>
    </xs:complexType>

    <xs:element name="oracle.dataaccess.client" type="oracledataaccessclienttype" />

    </xs:schema>
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points