ODP(Oracle Data Provider) Entity Framework and LINQ to Entities Installation Instructions, Setup, and Notes

Hi All,

I would like to share my experience of using Microsoft Entity Framework with Oracle Database.The main goal is using advance .Net Data Driven Architecture in Oracle.
You can create Entity Data Model (EDM) from existing Oracle Database Schema by Entity Data Model Wizard or run LINQ query against database or call stored procedure .

Oracle releases beta version of ODAC 11.2.0.2.30 (followhttp://www.oracle.com/technetwork/topics/dotnet/downloads/odacefbetainstallinstructions-302527.html if the url is out-of-the date please ask google.com :)).This provider supports Microsoft Visual Studio 2010 with SP1.

You can download and install easily.There is no serious problem during installation or integrating with Visual Studio Family.Just verify that C:\app\user>\product\11.2.0\client_\Oracle.Key file has correct value.(ex path; C:\app\MuhammetATALAY\product\11.2.0\client_2)

Here is step by step instruction:

1- Add New ADO.NET Entity Dta Model by right click project - Add - New Item
2- Generate From Database or Create Empty Model (Generate From Database will select)
3- Choose Data Connection.Picklist (Combobox - DropDown) should have item(s).If not exists any item related with Oracle.Please add Data Connections from Server Explorer in VS2010.
4- Choose Database objects you may need.An .edmx file will be created automatically.
5- You can follow the design.you can add new entity or relation to objects.You can also generate sql statement against oracle database by right clicking mouse>Generate Database From Model..(you will probably face a problem during executing generated Sql Statement.The error may be related with provider.)
6- The system can create class based on model by right clicking mouse>Add Code Generation Item.
7-After selecting context , a file that has .tt extension will be created.All objects are inherited ADO.NET class.

here is some sample to do for newly created context/class:

EntitiesOracle oracle = new EntitiesOracle();
ENTITYBASICDETAILSET basicDetailSet = new ENTITYBASICDETAILSET();
basicDetailSet.CODE = strCode;
//select from statement 1
var records = from rows in oracle.ENTITYBASICSET
where rows.NAME == strParentName
select new { rows.ID, rows.NAME } ;
//loop for each results
foreach (var id in records)
basicDetailSet.ENTITYBASICID = id.ID;


//select from statement 2
var OraLINQ2 = oracle.ENTITYBASICSET.Where(emp => emp.NAME == strParentName);
foreach (var result in OraLINQ2)
basicDetailSet.ENTITYBASICID = result.ID;

//select count(*)....
basicDetailSet.ID = oracle.ENTITYBASICDETAILSET.Count() + 1;

//INSERT INTO
oracle.ENTITYBASICDETAILSET.AddObject(basicDetailSet);
oracle.SaveChanges();

good luck...

some screen shots :













P.S:Please do not hesitate to share your comments.

Comments

  1. The_MATY

    Kellerman Software has an Oracle LINQ provider
    https://www.kellermansoftware.com/p-47-net-data-access-layer.aspx

    ReplyDelete

Post a Comment

Popular posts from this blog

Assembly Microsoft.Dynamics.Service.Plugins.dll can not be loaded. Dynamics CRM 365 Engine version 9 - CRM User creation error

Exception caught instantiating TERADATA report server extension SQL Reporting Services

Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified at Configuration class initiation in CrmServiceHelper.cv