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.
dotConnect for BigCommerce fully supports ADO.NET Entity Framework, including Entity Framework Core.
The article consists of the following sections:
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:
dotConnect for BigCommerce allows using it in Entity Framework models in various ways. You can use our provider with standard Visual Studio Entity Framework tools, in the same way as SqlClient.
For example, you can create an Entity Framework model, using database-first approach (for Entity Framework v4 - v6) in the following way:
dotConnect for BigCommerce also provides advanced ORM designer and code generation tool - Entity Developer. It allows creating Entity Framework v4 and Entity Framework Core models using database-first, model-first, or mixed approaches and generating code for them.
For your convenience there is a brief Entity Framework Tutorial that you can use to get acquainted with the technology.
dotConnect for BigCommerce also supports Visual Studio LightSwitch, so you can develop LightSwitch applications with our provider.
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.Bigcommerce" type="Devart.Data.Bigcommerce.Entity.BigcommerceEntityProviderServices, Devart.Data.Bigcommerce.Entity.EF6, Version=1.0.0.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
to the entityFramework -> providers section.
<entityFramework> <providers> <provider invariantName="Devart.Data.Bigcommerce" type="Devart.Data.Bigcommerce.Entity.BigcommerceEntityProviderServices, Devart.Data.Bigcommerce.Entity.EF6, Version=1.0.0.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> </providers> </entityFramework>
Note: replace 1.0.0.0 with the actual assembly version.
If it suits for your project, you may omit the exact assembly version:
<entityFramework> <providers> <provider invariantName="Devart.Data.Bigcommerce" type="Devart.Data.Bigcommerce.Entity.BigcommerceEntityProviderServices, Devart.Data.Bigcommerce.Entity.EF6" /> </providers> </entityFramework>
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.
dotConnect for BigCommerce currently supports Entity Framework Core. Entity Framework Core is supported only for the Full .NET Framework platform of version 4.5.1 and higher.
Database-First via Package Manager Console and the Scaffold-DbContext command is supported.
In order to use Entity Framework Core for Full .NET Framework, you need Visual Studio 2013 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.
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 BigCommerce provides the following extension methods:
When deploying Entity Framework projects, it is necessary to:
<system.data> <DbProviderFactories> <remove invariant="Devart.Data.Bigcommerce" /> <add name="dotConnect for BigCommerce" invariant="Devart.Data.Bigcommerce" description="Devart dotConnect for BigCommerce" type="Devart.Data.Bigcommerce.BigcommerceProviderFactory, Devart.Data.Bigcommerce, Version=1.0.0.0, Culture=neutral, PublicKeyToken=09af7300eec23701" /> </DbProviderFactories> </system.data>
Replace 1.0.0.0 here with your actual version.
You can find the assembly 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 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.
By Microsoft design, DbContext.SaveChanges() should work within a distributed transaction, but it is not supported by API of BigCommerce. That's why SaveChanges() will submit all DML operations (till the failed one, if any).
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.
Entity Framework Tutorial | http://blog.devart.com/tag/entity-framework