The ADO.NET Entity Framework (EF) Core is a lightweight and extensible object-relational mapper (O/RM) for .NET that supports cross-platform development. It allows developers to work with the database using .NET objects and helps them decrease the amount of code that needs to be written and maintained in data-centric applications.
The Zen ADO.NET Entity Framework Core data provider can be used with applications that use the ADO.NET Entity Framework Core. It supports:
The ADO.NET Entity Framework Core data provider uses the ADO.NET data provider to communicate with the ADO.NET database server. This means that the functionality defined by the ADO.NET data provider applies to the ADO.NET Entity Framework Core data provider unless otherwise noted here. Similarly, any performance configurations made to the ADO.NET data provider are realized by the ADO.NET Entity Framework Core data provider.
Note: Visual Studio 2017 or later is required when developing applications for the Zen ADO.NET Entity Framework Core.
About the ADO.NET Entity Framework Core Data Provider
The ADO.NET Entity Framework Core data provider is built with 100% managed code; it can run and connect to the database entirely within the common language runtime (CLR).
Code that runs in the native operating system, such as client libraries and COM components, is called unmanaged code. You can mix managed and unmanaged code within a single application. However, unmanaged code reaches outside the CLR, which means that it effectively raises complexity, reduces performance, and opens possible security risks.
Namespace
The namespace for the ADO.NET Entity Framework Core data provider is Actian.EntityFrameworkCore.Zen.
Assembly Names
The Zen ADO.NET Entity Framework Core data provider uses the assembly name Actian.EntityFrameworkCore.Zen.dll.
To use it, download the latest SDK .zip archive and extract the NuGet package Actian.EntityFrameworkCore.Zen for your version as listed under ADO.NET Data Providers Available with SDK Download. Then add the package to your project.
Configuring ADO.NET Entity Framework Core Data Provider
►To configure Zen ADO.NET Entity Framework Core Data Provider
Using Connection Strings with the Zen ADO.NET Entity Framework Core Data Provider
The Zen ADO.NET Entity Framework Core data provider uses information contained in connection strings to connect to the underlying ADO.NET data provider that supports the Entity Framework Core.
Changes in Default Values for Connection String Options
Most default values of the connection string options used by the ADO.NET Entity Framework Core data provider are the same as those used by the Zen ADO.NET data provider (see Table 35 for more information). Table 21 lists the connection string options that have a different default value when used with an ADO.NET Entity Framework Core application.
Table 21 Default Values of Connection String Options Used in an ADO.NET Entity Framework Core Application
Connection String Option
Default Value in ADO.NET Entity Framework Core Application
Entity Framework Core supports Code First features. Implementing support for these features requires changes to the data provider, including those required to handle long identifier names. However, it does not need any changes to your application.
Code First implementations require type mapping changes. See Type Mapping for Code First for more information.
Handling Long Identifier Names
Most Zen identifiers have a maximum length of 20 bytes. The identifier name can exceed this size because the names of the objects to be created on the server are taken from the class and property names. In addition, constraint names are often created by concatenating several object names. In these cases, the chances of exceeding the maximum identifier length are even greater.
For columns, the data provider shortens identifiers to the maximum identifier length allowed by the database, replacing the end of the identifier with a tilde character ~. For example, the string ColumnMoreThanTwentyCharacters is shortened to ColumnMoreThanTwent~.
For tables, the data provider shortens identifiers to the maximum identifier length allowed by the database, replacing the end of the identifier with an integer hash-code. For example, the string ATableWithAVeryLongTableName is shortened to ATableWit_1738385675.
If you access or view the DB object using a DB tool, the names of the created tables may differ from what you might expect based on model class names and property names.
Using Code First Migrations with the ADO.NET Entity Framework Core
Entity Framework Core supports the Code First Migrations feature, which enables you to update your database schema to reflect model classes without having to drop and recreate them.
Migrations enable you to incrementally evolve your database schema as your model changes. Each set of changes to the database is expressed in a code file, known as a migration. The migrations are ordered, typically using a time stamp, and a table in the database keeps track of which migrations are applied to the database.
To implement Code First Migrations, once you have configured the Zen ADO.NET Entity Framework Core Data Provider, install the following NuGet package:
Microsoft.EntityFrameworkCore.Tools (version 3.1)
Using Reverse Engineering (Scaffolding)
The process of scaffolding entity type classes and a DbContext class based on a database schema is called reverse engineering. You can perform it using either the Scaffold-DbContext command of the EF Core Package Manager Console (PMC) tools or the dotnet ef dbcontext scaffold command of the .NET Command-line Interface (CLI) tools.
To use reverse engineering with the ADO.NET Actian Zen Entity Framework Core Data Provider, perform the following steps after you have configured the data provider:
1 Install the following NuGet package: Microsoft.EntityFrameworkCore.Tools (version 3.1).
2 Run the following Scaffold-DbContext PowerShell command:
1. Maps to this type if no value is specified for MaxLength.
2. By default, maps to this type.
Mapping EDM Canonical Functions to Zen Functions
The ADO.NET Entity Framework Core translates the Entity Data Model (EDM) canonical functions to the corresponding data source functionality for the Zen ADO.NET Entity Framework Core Data Provider. The function invocations are expressed in a common form across data sources.
Because these canonical functions are independent of data sources, argument and return types of canonical functions are defined in terms of types in the EDM. When an Entity SQL query uses canonical functions, the appropriate function is called at the data source.
Both null-input behavior and error conditions are explicitly specified for all canonical functions. However, the ADO.NET Entity Framework Core does not enforce this behavior.
Aggregate Canonical Functions
Table 23 describes the mapping of EDM aggregate canonical functions to Zen functions, and also the CLR types to which these functions apply.
Table 23 Mapping Aggregate Canonical Functions
Aggregate Canonical Function
Actian Zen functions
CLR Type
BigCount(expression)
COUNT_BIG(expression)
Long
Count(expression)
COUNT(expression)
Int
Math Canonical Functions
Table 24 describes the mapping of EDM math canonical functions to Zen functions, and also the CLR types to which these functions apply.
Table 24 Mapping Math Canonical Functions
Math Canonical Function
Actian Zen Function
CLR Type
Abs(expression)
ABS(expression)
Decimal, Double, Float, Int, Long, SByte, Short
Ceiling(expression)
CEILING(expression)
Decimal, Double
Floor(expression)
FLOOR(expression)
Decimal, Double
Pow(base, power)
POWER(base, power)
Double
Exp(expression)
EXP(expression)
Double
Log10(expression)
LOG10(expression)
Double
Log(expression)
LOG(expression)
Double
Sqrt(expression)
SQRT(expression)
Double
Acos(expression)
ACOS(expression)
Double
Asin(expression)
ASIN(expression)
Double
Atan(expression)
ATAN(expression)
Double
Atan2(expression1, expression2)
ATAN2(expression1, expression2)
Double
Cos(expression)
COS(expression)
Double
Sin(expression)
SIN(expression)
Double
Tan(expression)
TAN(expression)
Double
Sign(expression)
SIGN(expression)
Decimal, Double, Float, Int, Long, SByte, Short
Date and Time Canonical Functions
Table 25 describes the mapping of EDM date and time canonical functions to Zen functions that generate, process, and manipulate types that work with data time data, and also the CLR types to which these functions apply.
Table 25 Mapping Date and Time Canonical Functions
Table 27 describes the mapping of EDM string canonical functions to Zen functions, and also the CLR types to which these functions apply.
Table 26 Mapping String Canonical Functions
String Canonical Function
Actian Zen Functions
CLR Type
IndexOf(expression)
POSITION(expression, column)
String
Replace(toReplace, replaceWith)
REPLACE(toReplace, column, replaceWith)
String
ToLower()
LOWER(column)
String
ToUpper()
UPPER(column)
String
SubString(start, length)
SUBSTRING(column, start, length)
String
IsNullOrWhiteSpace()
A combination of LTRIM and RTRIM with a null check on the column
String
TrimStart()
LTRIM(column)
String
TrimEnd()
RTRIM(column)
String
TRIM()
A combination of LTRIM and RTRIM on the column
String
Contains(expression)
POSITION(expression, column)
String
StartsWith(expression)
A combination of LEFT and LENGTH on the column
String
EndsWith(expression)
A combination of RIGHT and LENGTH on the column
String
Length()
LENGTH(column)
String
EF.Functions.Position(column, expression)
POSITION(expression, column)
String
Other Canonical Functions
Table 27 describes the mapping of other canonical functions to Zen functions, and also the CLR types to which these functions apply.
Table 27 Mapping Other Canonical Functions
Canonical Function
Actian Zen Function
CLR Type
ToString()
CONVERT(column, SQL_CHAR)
All types
NewGuid()
NEWID()
Guid
Note:Column is the property to which the function is applied.
Extending Entity Framework Functionality
The ADO.NET Entity Framework Core and Actian Zen Entity Framework Core data provider are designed to be extended easily. The following examples demonstrate how to extend Entity Framework Core: