locked
EF 4.1 Code First with Oracle Database RRS feed

  • Question

  • I am attempting to use the CodeFirst approach of EF4.1 with an Oracle database.  Is this possible yet?

    I am working through the sample here:  http://blogs.msdn.com/b/adonet/archive/2011/03/15/ef-4-1-code-first-walkthrough.aspx

    All works well when using the default SQLExpress database, however, when I add a connection string to my app.config file I get a "Table does not exist" exception.

     

     

      <connectionStrings>
        <add name="ProductContext" connectionString="User Id=myusername;Password=mypassord;Data Source=testdb;" providerName="Oracle.DataAccess.Client" />
      </connectionStrings>
    

     

    Is there something I am missing?  I was under the impression that the dbcontext would auto-create the tables during first execution as it did with SQLExpress.

     

    Tuesday, April 5, 2011 3:52 PM

Answers

All replies

  •  

    Hi rsknowles,

    Welcome!

    I heard that Oracle released its beta provider for EF recently: http://blogs.msdn.com/b/adonet/archive/2011/02/22/oracle-releases-beta-of-entity-framework-provider.aspx.  The blog indicates that Oracle provider includes LINQ to Entities, Model First development, and support for the Entity Data Model Wizard, but I'm not 100% sure whether it supports Code First too. I would recommend you consult it at the Oracle support channel here: http://forums.oracle.com/forums/forum.jspa?forumID=146.

    Thanks for understanding.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    • Marked as answer by rsknowles Sunday, April 17, 2011 12:31 AM
    Wednesday, April 6, 2011 6:53 AM
  • Hi rsknowles,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 12, 2011 6:07 AM
  • Thanks for following up.  I was unable to get Code First to work, but the other techniques worked well enough.

    Sunday, April 17, 2011 12:33 AM
  • Code First will work, I done some simple testing. No database generation, but mapping to an existing database was not a problem. I haven't explored complex scenarios, but had no issues loading data.

    A note though, the Oracle Provider for EntityFramework is beta and they will not support it in a production environment until it's out of beta so tread with caution. That and there are some big limitations with stored procs and Code First currently.

     I'd guess your problem with the table not found has to do with not specifying the schema first.

    Here's an example configuration that works with no problems for me:

    	public class MyObjectMappingEntityTypeConfiguration<MyObject>
    	{
    		public MyObjectMapping()
    		{
    			ToTable("SCHEMA_NAME.TABLE_NAME");
    			HasKey(m => m.MyObjectId);
    			Property(m => m.Number).HasColumnName("OBJECT_NUMBER");
    			Property(m => m.Name).HasColumnName("OBJECT_NAME");
    			Property(m => m.SomeString).HasColumnName("STRING_DATA");
    		}
    	}

     

     

    	<connectionStrings>
    		<add name="MyObjectContext" connectionString="Data Source=ObjectDB;user id=username;password=password" providerName="Oracle.DataAccess.Client.OracleConnection,Oracle.DataAccess,Version=2.112.2.30,Culture=neutral,PublicKeyToken=89b483f429c47342"/>
    	</connectionStrings>

     

     

     

    • Proposed as answer by DannyRih Wednesday, December 14, 2011 3:15 PM
    Monday, April 25, 2011 8:27 PM