none
Code First, DbContext and Oracle RRS feed

  • Question

  • Oracle says that their EF provider doesn't support Code First and DbContext API. But why is this? Isn't DbContext just a wrapper above ObjectContext?

    Nonetheless, I tried to build CF model and it worked!

    Can anyone please explain what exactly  is meant to be unsupported?

    Friday, October 5, 2012 2:52 AM

Answers

  • Dimitry,

    EF Code First DOES work with Oracle. The release documentation for the ODAC is a little bit misleading here. It says that Code First is not supported, but that does not mean that you cannot use Oracle Databases with Code First.

    There are a couple of things that do not work properly, but you can use workarounds. "Not supported" means that there are no special provisions e.g. for mapping Oracle database data types to EDM data types. Oracle uses data type "number" a lot, e.g. in our tables here they use number(1,0) for boolean values. "Not supported" means that Code First will NOT map number(1,0) to bool by convention. What is worse, you even cannot map these two manually - you HAVE to map number(x,y) to System.Decimal....

    Another workaround (I have not tested) is to add some mapping conventions to the app.config, like so:

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

    Besides of that, Oracle works well with Code First and DBContext.

    ...My 2 cents
    daProgramma

     


    • Edited by daProgramma Friday, October 5, 2012 7:46 AM
    • Proposed as answer by Alexander Sun Tuesday, October 9, 2012 2:02 AM
    • Marked as answer by Alexander Sun Tuesday, October 23, 2012 8:30 AM
    Friday, October 5, 2012 7:44 AM

All replies

  • Dimitry,

    EF Code First DOES work with Oracle. The release documentation for the ODAC is a little bit misleading here. It says that Code First is not supported, but that does not mean that you cannot use Oracle Databases with Code First.

    There are a couple of things that do not work properly, but you can use workarounds. "Not supported" means that there are no special provisions e.g. for mapping Oracle database data types to EDM data types. Oracle uses data type "number" a lot, e.g. in our tables here they use number(1,0) for boolean values. "Not supported" means that Code First will NOT map number(1,0) to bool by convention. What is worse, you even cannot map these two manually - you HAVE to map number(x,y) to System.Decimal....

    Another workaround (I have not tested) is to add some mapping conventions to the app.config, like so:

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

    Besides of that, Oracle works well with Code First and DBContext.

    ...My 2 cents
    daProgramma

     


    • Edited by daProgramma Friday, October 5, 2012 7:46 AM
    • Proposed as answer by Alexander Sun Tuesday, October 9, 2012 2:02 AM
    • Marked as answer by Alexander Sun Tuesday, October 23, 2012 8:30 AM
    Friday, October 5, 2012 7:44 AM
  • Hi Dmitry_npi,

    how did you do to build CF Model on an Oracle Database ? Can you explain me ?

    I tried but I can't generate a new table. I can change an existing table (add record) only.

    I have an exception when i  try to generate a model.???

    I am with the oracle provider odp.net

    thanks for your help

    Friday, October 12, 2012 8:47 AM