Entity Framework

Entity Framework 6 Support for Oracle, MySQL, PostgreSQL, SQLite and Salesforce

Thursday, January 17th, 2013

Entity Framework 6 Alpha 2 support is implemented in Devart ADO.NET providers: dotConnect for Oracle, dotConnect for MySQL, dotConnect for PostgreSQL, dotConnect for SQLite, and dotConnect for Salesforce. You need to download the corresponding Entity Framework NuGet package to use it in your applications. You can read about Entity Framework 6 features in the corresponding MSDN articles.

New Assemblies

In order to support Entity Framework 6, we have included new assemblies compiled under .NET Framework 4.0 to the installation packages of our providers. We have added the revision number "6" to the assembly versions to easily distinguish them from the corresponding Entity Framework v4/v5 assemblies.
(more…)

New Features in Entity Developer 5.0

Thursday, December 20th, 2012

Entity Developer 5.0 introduces a range of new features we hope you will find useful in your work. Starting with this version, Entity Developer supports DB2 and Firebird DBMSs and several third-party data providers. Besides, for the sake of your convenience, we have optimized certain features, added a number of new keyboard shortcuts and implemented the feature of transformation.

DB2 and Firebird Support

Starting with this version Entity Developer provides compatibility of Entity Framework and NHibernate models with DB2 and Firebird RDBMSs.

Third-Party Providers Support

From now on Entity Developer works with the following third-party providers:

Model Refactoring

The functionality of model refactoring greatly simplifies and automates such operations as creating complex types from properties, common to several entities, or creating TPT or TPC hierarchies from several entities. Now you can just select these entities on a diagram, right-click them, and select Model Refactoring from the shortcut menu. Then select the required action in the opened Model Refactoring Wizard and complete its steps, and Entity Developer will perform the selected action automatically.

Dialog Box Improvements for Entity Framework Models

The Property Editor dialog box is now enhanced with multiple options that were previously available only in the Properties docking window; now you can use it to specify code generation options, the corresponding object in the storage part, facet and validation framework settings.

The Inheritance Editor dialog box options have been extended to facilitate the process of TPH inheritance creation – now you don’t have to take extra steps and use the Mapping Details dialog, all you need is now available in one dialog box.

Configure Behaviour dialog box was renamed to Stored Procedure Mapping. Automapping of stored procedure parameters and class properties now works more efficiently in this dialog box. In some cases it even matches stored procedures with unnamed parameters, which is especially useful when working with PostgreSQL. Besides, two new check boxes have been added to this dialog box. One of them enables hiding stored procedures that are likely not to fit for mapping of certain action for a specific class. The other check-box enables hiding stored procedures that are already used in the model for Insert/Update/Delete mapping or as a method of the conceptual model.

Stored Procedure Mapping dialog box

New Options for Working with the Storage Part

Entity Developer 5.0 allows you to locate objects in the Storage part, that correspond to objects in the Conceptual part of the Entity Framework model. This can be done via the Select Storage shortcut menu item of the class, property, association and method. At the same time, the Create Storage and Mapping shortcut menu item allows you to create objects corresponding to classes, properties and associations existing in the Conceptual model but absent in the Storage part. The Storage field available in the Editor dialog boxes for classes, properties and methods enable quick and convenient mapping of these objects to their storage part counterparts.

Synchronization Improvements

We have improved column naming rules in the Storage part when synchronization is enabled. When a complex type property is added to a class, if the name of this property ends with the name of the corresponding complex type (e.g. CustomerAddress property within a class and the corresponding Address complex type), column names within the Storage part will contain the prefix taken from the property name, for example, Customer.

If, when creating an association between 2 classes, Entity Developer finds out that the names of the primary key columns are the same, a constraint property is created in the child class with the name that consists of the parent class foreign key name and the prefix equal to the parent class name:

New Keyboard Shortcuts

Entity Developer 5.0 introduces new keyboard shortcuts:

  • INSERT – pressing this shortcut key will create a new class or add a new property to a class, enum or complex type.
  • ALT+P – pressing this combination, when a class, enum or complex type is active calls the Property Editor dialog so that you could immediately configure a new property;
  • SHIFT+DELETE – this combination deletes the selected class, enum or complex type from the diagram area only;
  • DELETE – pressing this key will delete the object from the conceptual model together with the corresponding storage model objects.

Other Usability Improvements

In case you choose not to apply changes to some column or constraint when using Update To/From Database functionality, Entity Developer will ‘remember’ it and next time will not offer to apply changes to this object, i.e. in the Choose Actions tree the object will not be selected by default.

If a complex type is not mapped, this is now indicated in the Error List window with the corresponding warning message: The complex type ‘<type name>’ is not used by any object within the model.

Using Entity Framework Spatials with Oracle Spatial and SharpMap

Thursday, November 29th, 2012

Spatials Overview

Entity Framework v5 introduces spatial data types support. They are represented as two new DbGeometry and DbGeography data types from System.Data.Entity.dll in .NET Framework 4.5.

Many our Oracle users use Oracle Spatial functionality in their projects. Before Entity Framework v5 there was no easy way to use Oracle Spatial with Entity Framework, though users of PostgreSQL, PostGIS, and SharpMap could use this cumbersome and limited workaround. This workaround was even harder to use with Oracle Spatial and was almost not used because of numerous limitations.

Now Entity Framework v5 changes the situation, and Devart dotConnect for Oracle provides the best possible support for Entity Framework Spatials and Oracle Spatial. It includes new versions of Devart.Data.Oracle.Entity.dll and Devart.Data.Oracle.Entity.Migrations.dll assemblies built for .NET Framework 4.5 (Entity Framework v5) and the new unsigned Devart.Data.Oracle.Entity.SharpMap.dll assembly for SharpMap library support.
(more…)

Using PostgreSQL Full-Text Search in Entity Framework

Friday, August 17th, 2012

Introduction

PostgreSQL database supports an advanced functionality of full-text search (FTS) and full-text indexing described comprehensively in the documentation:

Full-Text Search

We decided to meet the needs of our users willing to take advantage of the full-text search in Entity Framework and implemented the full-text search functionality in our Devart dotConnect for PostgreSQL ADO.NET Entity Framework provider.
This article deals with the following:

(more…)

Using SQLite Full-Text Search in Entity Framework

Tuesday, August 14th, 2012

Introduction

SQLite database supports an advanced functionality of full-text search (FTS) and full-text indexing described comprehensively in the SQLite documentation: SQLite FTS3 and FTS4 Extensions.
We decided to meet the needs of our users willing to take advantage of the full-text search in Entity Framework and implemented the full-text search functionality in our Devart dotConnect for SQLite ADO.NET Entity Framework provider.
This article deals with the following:

(more…)

Using MySQL Full-Text Search in Entity Framework

Tuesday, July 10th, 2012

Introduction

MySQL database supports an advanced functionality of full-text search (FTS) and full-text indexing described comprehensively in the documentation:

We decided to meet the needs of our users willing to take advantage of the full-text search in Entity Framework and implemented the full-text search functionality in our Devart dotConnect for MySQL ADO.NET Entity Framework provider.
This article deals with the following:

(more…)

Using Oracle Full-Text Search in Entity Framework

Thursday, July 5th, 2012

Introduction

Oracle database supports an advanced functionality of full-text search (FTS) called Oracle Text, which is described comprehensively in the documentation:

We decided to meet the needs of our users willing to take advantage of the full-text search in Entity Framework and implemented the basic Oracle Text functionality in our Devart dotConnect for Oracle ADO.NET Entity Framework provider.
For working with Oracle Text specific functions in LINQ to Entities queries, the new OracleTextFunctions class is used, which is located in the Devart.Data.Oracle.Entity.dll assembly. It enables working with such Oracle Text functions as:

  • CONTAINS
  • CATSEARCH
  • MATCHES
  • SCORE
  • MATCH_SCORE

To call Oracle Text specific stored procedures of the CTX_DDL package, the OracleCtxDdlPackage class is used, which is located in the Devart.Data.Oracle.Entity.dll assembly.
To customize Code-First Migrations with the purpose of creating and deleting Oracle Text specific indexes, the CreateIndexConfiguration and DropIndexConfiguration classes are used, which are located in the Devart.Data.Oracle.Entity.Migrations.dll assembly.
This article deals with the following:

(more…)

Entity Framework Code-First Migrations support for Oracle, MySQL, PostgreSQL and SQLite

Monday, February 13th, 2012

ADO.NET EF providers Devart dotConnect for Oracle, dotConnect for MySQL, dotConnect for PostgreSQL, and dotConnect for SQLite implement support for Entity Framework 4.3 Beta 1 (Entity Framework Code-First Migrations). To use it in your applications, you need to download and install the corresponding Entity Framework NuGet package first. You can read about Entity Framework Code-First Migrations functionality in the corresponding MSDN articles.

Code-First Migrations Features

Entity Framework Code-First Migrations continues the development of Entity Framework Code-First functionality from Entity Framework 4.1 and Entity Framework 4.2, extending the functionality of dynamic database creating and deleting with the possibility of dynamic database schema modification (adding new columns/tables/foreign keys, creating and modifying existing database objects).

(more…)

Using Oracle Optimizer Hints in Entity Framework

Monday, January 23rd, 2012

With each new version of our Devart dotConnect for Oracle ADO.NET Entity Framework provider we pay special attention to improving its performance and configurability. It is pertinent to note some recent improvements: batch updates and flexible customization of Oracle Entity Framework provider behaviour. And now we are glad to present Oracle optimizer hints support in Entity Framework – a new feature for flexible tuning of SQL queries, generated by a user application.

Oracle Optimizer Hints

Oracle supports more than 60 different Oracle optimizer hints. You can see the complete list of Oracle optimizer hints and recommendations on their use in the Oracle Database documentation.

It is better to perform query optimization in external application, such as Devart dbForge Studio for Oracle, or any other tool for Oracle that you prefer. Queries, generated by Entity Framework, can be traced with dbMonitor and then copied and pasted to your SQL development application, where you can evaluate query performance, study execution plan, and choose optimizer hints to use.

Using Oracle Optimizer Hints as Oracle Function

Entity Framework provides not so many extensibility points for 3rd-party Entity Framework providers, so, to implement support for Oracle optimizer hints, we use database-specific functions feature in a non-standard way by adding the Devart.Data.Oracle.HINTS(string hints) function.

You can call this function directly in LINQ to Entities queries using the OracleFunctions class from the Devart.Data.Oracle.Entity assembly

var originalQuery = from emp in ctx.Exployees
                    ...
                    select emp;
var queryWithHints = originalQuery.Where(e => 
    OracleFunctions.Hints("INDEX(employees index1)"));
var result = queryWithHints.ToList();

or using query builder functionality of ObjectQuery (only when using ObjectContext, not DbContext).

var originalQuery = ctx.Exployees
                    .Where("Devart.Data.Oracle.HINTS('INDEX(employees index1)')")
                    ...
                    .Select(emp => emp);

Using Oracle Optimizer Hints as Extension Method

If you use ObjectContext, not DbContext, you can wrap this Devart.Data.Oracle.HINTS function and create an extension method, using the query builder feature of ObjectQuery.

public static class OracleExtensions {

    public static IQueryable<T> OracleHints<T>(
        this System.Data.Objects.ObjectQuery<T> source, string hints
    )
      where T : class {
      if (source == null)
        throw new ArgumentNullException("source");
      return source.Where("Devart.Data.Oracle.HINTS('" + hints + "')");
    }
}

Then you can use it in the following way:

var query = from emp in ctx.Exployees.OracleHints("FULL(employees) PARALLEL(employees, 5)")
            ...
            select emp;
var result = query.ToList();

Specifics and Limitations of Oracle Optimizer Hints in dotConnect for Oracle

We decided to always place hints after the first, upper-level SELECT keyword because structure of a generated SQL query does not always correspond to the structure of the LINQ to Entities query structure, and there is no unambiguous way to specify hints for a specific subquery.

var query = from emp in ctx.Exployees.OracleHints("FULL(employees) NOCACHE(employees)")
            ...
            select emp;
SELECT /*+ FULL(employees) NOCACHE(employees) */ last_name
  FROM employees;
...

If several hints are used, they are united in a single one.

var query = ctx.Employees
            ...
            select emp;
query = query.Where(e => OracleFunctions.Hints("FULL(employees)"));
query = query.Where(e => OracleFunctions.Hints("NOCACHE(employees)"));
SELECT /*+ FULL(employees) NOCACHE(employees) */ last_name
  FROM employees;

You cannot use string variables as OracleFunctions.Hints parameters, only string literals are allowed. For example, the following literal can be used:

var query = ctx.Employees.Where(e => OracleFunctions.Hints(
     "PARALLEL_INDEX(employees, index1, 3)"
));

and the following variable cannot:

string hints = "PARALLEL_INDEX(employees, index1, 3)";
var query = ctx.Employees.Where(e => OracleFunctions.Hints(hints);

Afterword

Thus, now dotConnect for Oracle Entity Framework provider has a new feature for flexible customization of SQL generation. Surely, Oracle optimizer hints is not a silver bullet and cannot solve all your problem, besides, one need some specific knowledge to use them. However, Oracle optimizer hints can be very useful in some cases, especially when changing database structure (creating/editing/deleting indexes, etc.) cannot be done for some reason. Oracle optimizer hints should be considered as one of the useful tools for developing applications using Entity Framework.

Set Identity and Computed Properties in Entity Framework Without Triggers

Tuesday, August 9th, 2011

This article deals with the following:

(more…)


dotConnect Team Blog