Tuesday, March 15, 2011

Using Entity Framework and Oracle database

Have been busying on using Entity Framework for Oracle database.
My new project require a rapid development on prototyping. I am responsible to setup this.
To support fast requirement gathering pace. I decided to write an web application based on Entity Framework.
At the same time, our team is testing the ease of Entity Framework. Most important is the performance that need to take into consideration.

  Challenges:-

Challenge number 1 We are connecting to oracle database 11g. Not MS SQL.
This is main challenge as Entity Framework that I have been using is connecting to Microsoft SQL server. I have been gone thru some online forum comments saying that it's hard to connect to oracle via .NET due to some hidden agenda between Oracle and Microsoft. Think with common sense we help us to understand here.

After spending some time, I have been amazed that the Oracle actually building "Oracle Data Access Components (ODAC) for Microsoft Entity Framework and LINQ to Entities". The beta release dated on February 10, 2011. You can dowload the installation here.

http://www.oracle.com/technetwork/topics/dotnet/downloads/oracleefbeta-302521.html
Before installing, please read the next challenge.

This is great release, as we can now talking to Oracle database with Microsoft's Entity Framework.

Challenge number 2 the Oracle client will stop working after installing these package
Your PL/SQL Developer will stop working. You will not able to get the database. I found everything is OK with my Oracle home folder is ok. tnsname.ora is still good in shape. I even reinstall my Oracle client and PL/SQL developer. Finally I found this supportive forum,
http://forums.oracle.com/forums/thread.jspa?threadID=620900&tstart=0

Simply copying files (not folders) from

C:\app\your user name\product\11.2.0\client_2   << client_2 due to multiple installations

to

C:\app\your user name\product\11.2.0\client_2\bin

and it works..

But what has the installer done!!! Is this a work around?


Challenge number 3 Learning to use the entity framework
This is not a challenge to me, I have been using this for MS SQL. Please refer to this detail document.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/EntityFrameworkOBE/EntityFrameworkOBE.htm

Challenge number 4 Using Function Import to call the store procedured.
This is where I give up with the procedure call. Entity framework tend to not recommend you to call store procedures. However, there cases that you want to use procedures for some business logic. In our case, we simply want it's speed and stability after hearing a lot of complain on Entity framework.

Call procedures is not straight forward. I am talking about calling the procedures and without using the entities. A new kind of entity will be declare or created which is named Implicit Resultsets. The worst thing and irresponsible above training URL did is leave us figuring out how to put the metadata information into web.config (app.config). If the implicit resultsets consists of a lot of columns, the mapping will be painfully done. After struggling for few hours, I decided to call the store procedure and without bordering these metadata configuration. Can I do that? This totally defeat the purpose of using the model first methodology.


After few try and error, I have come to a point that ODAC for Entity Framework is not ready for production.







1 comment:

  1. I love this post – totally kewl!!! Well done! I’m coming back to this one …
    toolbar generator

    ReplyDelete