This discussion is archived
11 Replies Latest reply: Oct 29, 2012 8:25 PM by 971300 RSS

Bool and Code First

932776 Newbie
Currently Being Moderated
Hi,

I'm trying entity framework code first approach. Now i have a problem with mapping of type bool to number(1, 0). When i run my application, the following exception occurs. Can you help me?
I use ODP.NET verison 11.2.0.3.0

Schema specified is not valid. Errors:
(23,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.Boolean[Nullable=False,DefaultValue=]' of member 'IsActive' in type 'MyTest.Workflow' is not compatible with 'OracleEFProvider.number[Nullable=False,DefaultValue=,Precision=38,Scale=0]' of member 'IsActive' in type 'CodeFirstDatabaseSchema.Workflow'.

Thanx
  • 1. Re: Bool and Code First
    932814 Newbie
    Currently Being Moderated
    Hi there,

    I had the same error with my project. I have fix the issue successfully by adding in the configuration section of web.config or app.config file :

    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    </settings>
    </oracle.dataaccess.client>

    Settings should be added in both project : runtime and entities project.

    For you the solution might be to map the bool with an number(38,0) ?

    Edited by: user1087355 on 24 avr. 2012 03:12
  • 2. Re: Bool and Code First
    932776 Newbie
    Currently Being Moderated
    I added following configuration section to my web.config, but i got another exception.

    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(38,0)" />
    </settings>
    </oracle.dataaccess.client>


    The type initializer for 'Oracle.DataAccess.Client.RegAndConfigRdr' threw an exception.
    INT16 is invalid
  • 3. Re: Bool and Code First
    932814 Newbie
    Currently Being Moderated
    No idea for the exception.

    What is the database type for IsActive ? Number(38)?

    For a boolean, might be better to have a IsActive with type Number(1) in the Database and then do the following mapping

    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    </settings>
    </oracle.dataaccess.client>
  • 4. Re: Bool and Code First
    932776 Newbie
    Currently Being Moderated
    No. IsActive is number(1,0) in database.
  • 5. Re: Bool and Code First
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated
    If IsActive is a NUMBER(1,0), then you should map a NUMBER(1,0) to bool, rather than NUMBER(38,0).

    user1087355 has the right idea.
  • 6. Re: Bool and Code First
    932776 Newbie
    Currently Being Moderated
    when i set following configuration. No change occured. Application threw same exception.

    <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    </settings>

    Schema specified is not valid. Errors:
    (23,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.Boolean[Nullable=False,DefaultValue=]' of member 'IsActive' in type 'MyTest.Workflow' is not compatible with 'OracleEFProvider.number[Nullable=False,DefaultValue=,Precision=38,Scale=0]' of member 'IsActive' in type 'CodeFirstDatabaseSchema.Workflow'.
  • 7. Re: Bool and Code First
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated
    Officially, Oracle doesn't support Code First just yet, though I would expect numerous operations to just work with Code First. Does the mapping error also occur with DB First?

    What version of EF are you using?
  • 8. Re: Bool and Code First
    nswandel Newbie
    Currently Being Moderated
    Hi! I feel your pain. I have had some similar issues and have made a few discoveries that have allowed me to get around these issues through a couple of ODAC releases. I just upgraded from the previous beta 3. With the beta 3 I found that any time the .edmx was changed or validated I would get these errors. I could get rid of the errors by moving my edmmapping in the App.Config from on place to another and rebuilding. Very annoying, but I could proceed. Sometimes the errors would return seemingly without cause, but my kludgey fix would get rid of them. The reasons for the issue or why my recurring fix works are beyond me. It will differ a bit depending on what you are remapping, but this is the piece I move around.

    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(1,0)"/>
    </settings>
    </oracle.dataaccess.client>

    Now I have downloaded the current release ODAC 11.2 Release 4 (11.2.0.3.0) and my ludgy fix no longer gets rid of the errors. Well it is always good to know someone who has suffered .NET development longer than you. I was whine to my more experienced friend and he knew of the issue and it is not restricted to Oracle. He has experienced this issue with SQL Server and mySQL as well. He found a fix by accident after much suffering (no claim of brilliance) and why it works is a mystery. If I click on the designer background and "Generate Database from Model…" and save the file to my project then my issues are gone. I am told I may have to occasionally do this again if the issues reappear. The presence of the file is benign and solves my issues. Let me know if the works for you.
  • 9. Re: Bool and Code First
    939572 Newbie
    Currently Being Moderated
    I only got this working 50% because I am trying to use two different entity models at the same time. One model requires this:

    <oracle.dataaccess.client>
    <settings>
    <add name="bool" value="edmmapping number(1,0)" />
    </settings>
    </oracle.dataaccess.client>

    But the other model does not.

    However, the above mentioned configuration section applies to the whole application.

    How can I fix this mapping in the entity model itself instead of from the web.config?

    Thanks!

    Robert
  • 10. Re: Bool and Code First
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated
    The only solution right now is to create two projects, each with its own config file.
  • 11. Re: Bool and Code First
    971300 Newbie
    Currently Being Moderated
    jupin, i faced same to you , did you fixed it ? i`m so tired to google it , most thread is use EDMX .

    Last year i used EF4.1 on sqlserver 2008, Code First , it works well. but now ,we must change DB to Oracle , i have read some article,i download ODAC 4

    my column is real Number(1), but the error is still (Precision=38,Scale=0) so strange

Legend

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