Have you been looking for a solution to connect Entity Framework and Oracle? In this blog post, I will show how to integrate Entity Framework 6 with Oracle database, through a step by step implementation.
Let’s begin.
Start a new project
Before adding a new project, you need to install ODP.NET and ODAC from here. Install 64-bit ODAC 12c Release 3 (12.1.0.2.1) for Windows x64. This will work for visual studio 2013.
After installing, run the setup once and restart your system. Then follow the below steps:
-
- Â Open Visual Studio 2013 and add a project.
-
- Add Entity Data Model by right clicking on the project in the solution explorer – Add -> click New Item and select ADO.NET Entity Data Model from the popup. Click Add button.
-
- Entity Data Model Wizard opens with four options to select. We will focus on the database-first approach, so select EF Designer from database option and click Next.
-
- You can choose from your existing DB Connections or create a new connection by clicking the New Connection button. This will also add a connection string to your app.config file with default suffix as database name. Click Next after you set up your database connection.
-
- Now when you will click on Next, it will give an error as below:
-
- To resolve this error, we need to add Oracle 12c version by NuGet packages and search oracle. Right click on Project ->Manage Nuget Packages ->Browse for Oracle then add the following.
-
- After installing the oracle 12c, the above error is resolved. Then you can add the entity framework and include all the tables as desired.
-
- After clicking on Finish, an edmx file will be added into your project. EDM also adds a connection string in the app.config file.
Conclusion
Configuring Entity Framework 6 to work with Oracle database is now doable. In earlier versions, Nuget Manager Installation was not available, but now it is available and working successfully. In in my next blog, I will be talking about Entity framework configuration management and deployment with Oracle database. Stay tuned for more.