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, DB2, and Salesforce.
The article consists of the following sections:
- What is ADO.NET Entity Framework?
- Entity Framework Support Key Features
- Using the Entity Data Provider
- Deploying an Entity Framework Project
- Visual Model Creation
- Compatibility and Requirements
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.
- Conceptual approach to enterprise development
- High performance
- Wide support for LINQ to Entities capabilities
- 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
Use of dotConnect for Oracle in the Entity Framework is similar to use of standard SqlClient. Generally it conforms to the following scheme:
- Open your project.
- Add new item ADO.NET Entity Data Model to your project and specify its name.
- Choose Generate from database.
- Choose the dotConnect you use as data provider and specify the connection string.
- 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.
- 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.
When deploying Entity Framework projects, it is necessary to:
- Check if the required assemblies Devart.Data.dll, Devart.Data.Oracle.Entity.EF*.dll, and Devart.Data.Oracle.dll are available for your application, where * is a number of Entity Framework version used or "Core" for Entity Framework Core. The assemblies should reside in GAC or in the application's folder.
- If you use Code-First Migrations, you also need to check if the Devart.Data.Oracle.Entity.Migrations.EF*.dll assembly is available for your application.
For Entity Framework v1 - v6, inform your environment about the provider factory existence (add the entry to the DbProviderFactories section). This step is not needed for Entity Framework Core. This can be done as follows:
<system.data> <DbProviderFactories> <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=7.8.301.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> </DbProviderFactories> </system.data>
Replace 7.8.301.0 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 - v6 - specific applications should be registered in the .NET Framework 4.0 configuration file. This step is not needed for Entity Framework Core.
You can also read Micrsoft's Deployment Considerations on ADO.NET Entity Framework.
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.]
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: 22.214.171.124 or higher
- MySQL: 5.0 or higher
- PostgreSQL: 8.0 or higher
- SQLite: any supported version
- DB2: 9 and higher