Entity Framework Support in ADO.NET Provider for Oracle

The latest ADO.NET evolution focuses on raising the level of abstraction from the logical (relational) level to the conceptual (entity) level. For this purpose Microsoft introduces the Entity Framework, designed to simplify data - object conversion and embed data access queries into program code.

The Devart dotConnect product line supports the ADO.NET Entity Framework for the following databases: Oracle, MySQL, PostgreSQL, SQLite, DB2, and the following cloud applications: Salesforce, Dynamics CRM, SugarCRM, Zoho CRM, MailChimp, Salesforce Marketing Cloud (formerly, ExactTarget), Bigcommerce, Magento, QuickBooks, and FreshBooks.

The article consists of the following sections:

What is ADO.NET Entity Framework?

The Entity Framework is a set of technologies in ADO.NET that support development of data-oriented software applications. The Entity Framework is designed to enable developers to create data access applications by programming against a conceptual application model instead of programming directly against a relational storage schema. The goal is to decrease the amount of code and maintenance required for data-oriented applications. Entity Framework applications provide the following benefits:

  • Applications can work in terms of a more application-centric conceptual model, including types with inheritance, complex members, and relationships.
  • Applications are freed from hard-coded dependencies on a particular data engine or storage schema.
  • Mappings between the conceptual model and the storage-specific schema can change without changing the application code.
  • Developers can work with a consistent application object model that can be mapped to various storage schemas, possibly implemented in different database management systems.
  • Multiple conceptual models can be mapped to a single storage schema.
  • Language-integrated query support provides compile-time syntax validation for queries against a conceptual model.

Entity Framework Support Key Features

  • Conceptual approach to enterprise development
  • High performance
  • Wide support for LINQ to Entities
  • Wide support for EntitySQL
  • Full CRUD (Create, Retrieve, Update, Delete) support
  • Wide support for server data types
  • Capability to use stored procedures when manipulating data
  • Stored procedure import support
  • Visual Studio EDM Wizard support(reverse engineering of database objects to entity model)
  • Visual Studio LightSwitch support
  • Generate Database Wizard (Model-First) support
  • Configurable Code-First CreateDatabase/DatabaseExists/DropDatabase functionality support
  • Support for Code-First Migrations with database-specific features
  • Entity Framework Spatials support
  • Support for database-specific system functions in LINQ to Entities and Entity SQL
  • Full-text search support
  • Batch updates
  • Entity Framework provider configuration

Using the Entity Data Provider

Use of dotConnect for Oracle in the Entity Framework is similar to use of standard SqlClient. Generally it conforms to the following scheme (for Entity Framework v1 - v6):

  1. Open your project.

  2. Add new item ADO.NET Entity Data Model to your project and specify its name.

  3. Select Generate from database.

  4. Select the dotConnect you use as data provider and specify the connection string.

  5. Select tables that are actually used in your project and click Generate to finish the process. If the selected tables contain foreign keys, they will be reflected in the generated models as well.

  6. Specify a name for the model namespace. Note that this name should be different from the database (schema) name.

For your convenience there is a brief Entity Framework Tutorial that you can use to get acquainted with the technology. You can also take a look at Entity Framework samples available with the product, or download separate Entity Framework Query Samples package. The latter is a standard Microsoft demo with added Oracle/MySQL/PostgreSQL/SQLite connectivity.

Using the Entity Data Provider with Entity Framework v6

Since there are no global Entity Framework provider registration for Entity Framework v6, you should register our provider manually in the config file of your project. For this you should add the following line:

<provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, 
Devart.Data.Oracle.Entity.EF6, Version=, Culture=neutral, PublicKeyToken=09af7300eec23701" />

to the entityFramework -> providers section.

      <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, 
      Devart.Data.Oracle.Entity.EF6, Version=, Culture=neutral, PublicKeyToken=09af7300eec23701" />

Note: replace with the actual assembly version.

If it suits for your project, you may omit the exact assembly version:

        <provider invariantName="Devart.Data.Oracle" type="Devart.Data.Oracle.Entity.OracleEntityProviderServices, Devart.Data.Oracle.Entity.EF6" />

This section appears in the project config file only after you add the NuGet EntityFramework package either explicitly, by executing the "install-package EntityFramework" command, or implicitly, by adding an Entity Framework v6 model for SQL Server via EDM Wizard.

Using the Entity Data Provider with Entity Framework Core

dotConnect for Oracle currently supports Entity Framework Core. Entity Framework Core is supported for the Full .NET Framework platform of version 4.5.1 and higher and for .NET Core. Dynamic database object creation (tables/FK/PK/indexes/triggers/sequences) based on an Entity Framework model is supported. See our Entity Framework Core Code-First Tutorial for Full .NET Framework and for .NET Core in dotConnect for Oracle documentation.

Database-First via Package Manager Console is supported. See our Entity Framework Core Database-First Tutorial for Full .NET Framework and for .NET Core in dotConnect for Oracle documentation.

Please note that only a part of Entity Framework provider configuration settings is supported for Entity Framework Core. Also, not all Entity Framework v6 features are supported because Entity Framework Core does not support a lot of Entity Framework v6 features itself.

In order to use Entity Framework Core for Full .NET Framework, you need Visual Studio 2013 or higher. For .NET Core you need Visual Studio 2017 or higher.

In order to register an Entity Framework provider and set a connection string, you need to override the OnConfiguring method of your DbContext class descendant.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
  optionsBuilder.UseOracle(@"User Id=Scott;Password=tiger;Data Source=Ora;");
[Visual Basic]
Protected Overrides Sub OnConfiguring(optionsBuilder As DbContextOptionsBuilder)

	optionsBuilder.UseOracle("User Id=Scott;Password=tiger;Data Source=Ora;")
End Sub

The mapping supported by Entity Framework Core is described in details in the corresponding section of Entity Framework documentation. If you plan to support several data sources for one base Entity Framework model, that is mapped to tables and columns named differently in different data sources, you can use special provider-specific extension methods in fluent mapping in order to support specific mapping for each data source simultaneously. dotConnect for Oracle provides the following extension methods:

  • ForOracleToTable() - specifies the table name.
  • ForOracleHasColumnName() - specifies the column name.
  • ForOracleHasColumnType() - specifies the column type.
  • ForOracleHasName() - specifies the the name of the index and primary key.
  • ForOracleHasConstraintName() - specifies the foreign key.
  • ForOracleHasDefaultValueSql() - specifies the column default value.

Deploying an Entity Framework Project

When deploying Entity Framework projects, it is necessary to:

  1. Check if the required assemblies Devat.Data.dll, Devart.Data.Oracle.dll, and Devart.Data.Oracle.Entity.EF<Version>.dll are available for your application. The <Version> here is the version of Entity Framework used in your application. For Entity Framework v1 the assembly is called Devart.Data.Oracle.Entity.EF1.dll "1", for Entity Framework v4 it is Devart.Data.Oracle.Entity.EF4.dll, for Entity Framework v5 and v6 it is Devart.Data.Oracle.Entity.EF5.dll or Devart.Data.Oracle.Entity.EF6.dll respectively. For Entity Framework Core it is Devart.Data.Oracle.Entity.EFCore.dll. The assembly should reside in the application's folder or in GAC.

    Please note that there are three versions of Devart.Data.Oracle.Entity.EFCore.dll assemblies for different Entity Framework Core versions - 1.1, 2.2, and 3.1. They are located respectively in \Entity\EFCore, \Entity\EFCore2, and \Entity\EFCore3 subfolders of the [!ProductName] installation folder.

  2. If you use Code-First Migrations feature of Entity Framework v4 or Entity Framework v5, you also need to check if the Devart.Data.Oracle.Entity.Migrations.EF<Version>.dll assembly is available for your application. For Entity Framework v6 this assembly is not needed.

  3. If you use Entity Framework Spatials and NetTopologySuite, you also need to check if the Devart.Data.Oracle.Entity.Spatials.EF<Version>.dll assembly is available for your application.

  4. For Entity Framework v1 - v6, you need to inform your environment about the provider factory existence (add the entry to the DbProviderFactories section as it is described above).

	<remove invariant="Devart.Data.Oracle" />
	<add name="dotConnect for Oracle" invariant="Devart.Data.Oracle"
	 description="Devart dotConnect for Oracle"
	 type="Devart.Data.Oracle.OracleProviderFactory, Devart.Data.Oracle,
       Version=, Culture=neutral, PublicKeyToken=09af7300eec23701" />

Replace here with your actual version.

You can find the necessary assemblies in the Entity folder in the provider installation folder, in the subfolder, corresponding to the Entity Framework version necessary.

If you are registering the provider in the machine.config file, please take into account the Entity Framework version. Entity Framework v1 - specific applications require an entry in the .NET Framework 2.0 configuration file, and Entity Framework v4 and later - specific applications should be registered in the .NET Framework 4.0 configuration file. For Entity Framework Core there is no need to register the provider in the machine.config file.

You can also read Micrsoft's Deployment Considerations on ADO.NET Entity Framework.

Visual Model Creation

dotConnects for MySQL, Oracle, PostgreSQL, SQLite, DB2, and Salesforce are tightly integrated with Visual Studio Entity Data Model Wizard for generating model definitions. dotConnects also include several demo projects that show how to use the product in conceptual programming against data.

Moreover, dotConnect providers have a bundled visual ORM model designer - Entity Developer . Entity Developer provides far more advanced model editing functionality than standard Visual Studio EDM Designer. It provides better support for Model-First and Database-First development wider mapping support, and powerful template-based code generation. Visit this webpage for more information on Entity Developer benefits.

dotConnect providers also support Visual Studio LightSwitch, so you can develop LightSwitch applications with our providers. You can find a tutorial on creating a simple LightSwitch application using dotConnect for Oracle here: Tutorial: How to Connect Visual Studio LightSwitch to Oracle with dotConnect for Oracle Data Provider .


We have applied our efforts to support the Entity Framework functionality (and particularly LINQ to Entities) as much as possible for the Oracle Server. And we have successfully implemented most features, but there are some limitations which cannot be overcome:

  • Oracle doesn't have its equivalents for the SQL Server OUTER APPLY and CROSS APPLY constructions (this issue is described at http://msdn.microsoft.com/en-us/library/bb896273.aspx). Microsoft decided not to change the current behaviour. So, users who encounter the mentioned obstacles should re-construct their LINQ-queries.
  • User-defined types, including Oracle objects, array types and nested tables are not supported.

You can get more information at our website.

All the provider documentation: dotConnect for Oracle Documentation
The Entity Framework section: https://docs.devart.com/dotconnect/oracle/EFSupport.html
The blog articles dedicated to Entity Framework: https://blog.devart.com/tag/entity-framework

Compatibility and Requirements

dotConnects for Oracle, MySQL, PostgreSQL, and SQLite are compatible with the latest release version of ADO.NET Entity Framework and Visual Studio. The following server versions are required for Entity Framework to function properly:

  • Oracle: or higher
  • MySQL: 5.0 or higher
  • PostgreSQL: 8.0 or higher
  • SQLite: any supported version
  • DB2: 9 and higher

Migration between ADO.NET Entity Data Model (*.edmx) and Devart Entity Model (*.edml)

To migrate your ADO.NET Entity Data Model to Devart Entity Model, change the extension of the model file to edml (edmx -> edml), set the Build Action property of your model to "DevartEntityDeploy", and Custom Tool to "DevartEfGenerator". After that the model can be edited with the Devart Entity Developer.

To migrate your Devart Entity Model to ADO.NET Entity Data Model, change the model file extension (edml ->edmx), set the Build Action property of your model to "EntityDeploy", and Custom Tool to "EntityModelCodeGenerator". After that the model can be edited with Entity Designer.

Both *.edml and *.edmx can be opened and edited manually using XML Editor.

Back to list