Click here to Skip to main content
12,885,268 members (42,831 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked
Posted 13 Jul 2012

Using Oracle with EntityFramework 4

, 13 Jul 2012 MIT
Rate this:
Please Sign up or sign in to vote.


I will introduce how to use Oracle with Entity Framework.


You should have VS2010, .NET Framework 4 or higher, Oracle 10g or higher version, ODAC 11.2 Release 4 ( with Oracle Developer Tools for Visual Studio (download from

Using the Code

First, create a table in your Oracle database:

CREATE TABLE test_tbl (
     id   INT,
     val  VARCHAR(10),
     PRIMARY KEY (id)

Now try to connect to Oracle with EF:

  1. Create project Open VS2010, create a console applicationNew | Project | | Console application
  2. Add ADO.NET Entity Data Model Right click the project | Add | New Item , Click "ADO.NET Entity Data Model ", and the default name is "Model1.edmx" , click "Add"

Choose "Generate from database", click "Next".

Click "New Connection... " setup the connection to the Oracle.

Choose the table and click "Finish".

VS2O1O will generate the entities for you.

Now , write code like the following:

static void Main(string[] args)
    using (Entities ctx = new Entities())
        var rst = from tbl in ctx.TEST_TBL
                  select tbl;
        foreach (var tbl in rst)

You can get values from Oracle.

Points of Interest

By now, we know how to deal with single table, further, we would research more table and the relationship between tables (one-to-one, one-to-many, etc.).


  • 2012.07.13 V1.0


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Web Developer
China China
So so

You may also be interested in...


Comments and Discussions

QuestionPoorest article ever Pin
giaophong2-May-16 22:07
membergiaophong2-May-16 22:07 
QuestionEntity Framework in Oracle Database Pin
Member 1203526514-Oct-15 17:36
memberMember 1203526514-Oct-15 17:36 
QuestionUpdate the entity - Regarding... Pin
Member 900750224-Jun-15 6:18
memberMember 900750224-Jun-15 6:18 
GeneralMy vote of 1 Pin
Member 103596779-Dec-14 14:33
memberMember 103596779-Dec-14 14:33 
GeneralMy vote of 4 Pin
Member 1082968027-May-14 2:24
memberMember 1082968027-May-14 2:24 
Question[My vote of 1] Poor article Pin
kiquenet.com12-Aug-13 20:57
memberkiquenet.com12-Aug-13 20:57 
AnswerRe: [My vote of 1] Poor article Pin
DaveWilliams11064-Nov-14 2:59
memberDaveWilliams11064-Nov-14 2:59 
GeneralMy vote of 5 Pin
Willie Lassiter15-Feb-13 11:30
memberWillie Lassiter15-Feb-13 11:30 
GeneralMy vote of 5 Pin
Dan Randolph17-Dec-12 6:08
memberDan Randolph17-Dec-12 6:08 
GeneralMy vote of 1 Pin
Klaus Luedenscheidt13-Jul-12 17:13
memberKlaus Luedenscheidt13-Jul-12 17:13 
GeneralRe: My vote of 1 Pin
wshcdr13-Jul-12 17:27
memberwshcdr13-Jul-12 17:27 
GeneralMy vote of 1 Pin
ashved13-Jul-12 16:57
memberashved13-Jul-12 16:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 14 Jul 2012
Article Copyright 2012 by wshcdr
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid