dotConnect for MySQLsupport@devart.com

Entity Framework Support

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 Oracle, MySQL, PostgreSQL, SQLite, and Salesforce.

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:

Entity Framework Support Key Features

Using the Entity Data Provider

Use of dotConnect for MySQL in the Entity Framework is similar to use of standard SqlClient. Generally it conforms to the following scheme:

  1. Open your project.
  2. Add new item ADO.NET Entity Data Model to your project and specify its name.
  3. Choose Generate from database.
  4. Choose 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 MySQL connectivity.

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.MySql.Entity.dll, and Devart.Data.MySql.dll are available for your application. The assemblies should reside in GAC or in the application's folder. Be aware that there are two versions of Devart.Data.MySql.Entity.dll in the provider installation folder - for Entity Framework v 1 and for Entity Framework v 4.
  2. If you use Code-First Migrations, you also need to check if the Devart.Data.MySql.Entity.Migrations.dll assembly is available for your application.
  3. Inform your environment about the provider factory existence (add the entry to the DbProviderFactories section). This can be done as follows:
<system.data>
  <DbProviderFactories>
    <remove invariant="Devart.Data.MySql" />
    <add name="dotConnect for MySQL" invariant="Devart.Data.MySql"
     description="Devart dotConnect for MySQL"
     type="Devart.Data.MySql.MySqlProviderFactory, Devart.Data.MySql,
       Version=7.5.202.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
  </DbProviderFactories>
</system.data>

Replace 7.5.202.0 here with your actual version.

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 - specific applications should be registered in the .NET Framework 4.0 configuration file.

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

Visual Model Creation

dotConnects for MySQL, Oracle, PostgreSQL, 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.

Compatibility and Requirements

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

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.

See Also

Entity Framework Tutorial | Devart LinqConnect

 

 


© 2002-2013 Devart. All rights reserved.