Developer Reference : Data Access Methods : Data Provider for .NET : The ADO.NET Entity Framework Core Data Provider
 
The ADO.NET Entity Framework Core Data Provider
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:
Microsoft ADO.NET Entity Framework Core 3.1
All the platforms supported by .Net Standard 2.1. For details, see https://docs.microsoft.com/en-us/dotnet/standard/net-standard.
All the features supported by both Microsoft Entity Framework Core and Actian Zen database. For details, see https://docs.microsoft.com/en-in/ef/core/what-is-new/.
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
1 Create an application that targets .Net Standard 2.1. For details, see https://docs.microsoft.com/en-us/dotnet/standard/net-standard.
2 Install the following NuGet package: Actian.EntityFrameworkCore.Zen.
3 Add a new context class to your application and override the OnConfiguring method using the following code:
public class MyContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseZen(connection string);
}
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
Parameter Mode
Not supported.
Statement Cache Mode
ExplicitOnly is the only supported value.
DB File Directory Path
Environment.SpecialFolder.CommonApplicationData. To know more about the Environment.SpecialFolder enum and the supported fields, see https://docs.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=netcore-3.1
Code First Support
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.
Code First Migrations requires type mapping changes. See Type Mapping for Code First for more information.
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:
Scaffold-DbContext 'connection string' Actian.EntityFrameworkCore.Zen
You can add more parameters to the Scaffold-DbContext PowerShell command, if required. To know more about it, see https://docs.microsoft.com/en-in/ef/core/managing-schemas/scaffolding?tabs=vs.
To use reverse engineering in .Net Core CLI environment, see https://docs.microsoft.com/en-in/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli.
Type Mapping for Code First
Mapping CLR Types to Actian Zen Data Types in a Code First Model shows the model-centric type mapping, where the CLR type influences the Zen (store) type used when the database is created. Some CLR types can map to several different Zen types.
The columns are defined as follows:
The CLR Type column refers to the common language runtime type name.
Property Values Affecting Type Mapping identifies any property value that can affect type mapping.
The Zen Type column refers to the native type name.
 
Table 22 Mapping CLR Types to Actian Zen Data Types in a Code First Model  
CLR Type
Property Values That Affect
Type Mapping
Actian Zen Data Type
Bool
 
BIT
Byte
 
UTINYINT
Byte[ ]
 
BINARY
 
LONGVARBINARY<superscript>1
DateTime
 
AUTOTIMESTAMP
 
DATE
 
TIMESTAMP
 
TIMESTAMP2<superscript>2
DateTimeOffset
 
DATETIME
Decimal
 
CURRENCY
 
 
NUMERIC
 
NUMERICSA
 
NUMERICSTS
 
UBIGINT
Double
 
BFLOAT8
 
Float
 
 
REAL
 
BFLOAT4
Guid
 
UNIQUEIDENTIFIER
Int
 
INTEGER<superscript>2
 
IDENTITY
 
USMALLINT
Long
 
 
BIGIDENTITY
 
UINTEGER
SByte
 
TINYINT
Short
 
SMALLINT<superscript>2
 
SMALLIDENTITY
String
 
NLONGVARCHAR<superscript>2
 
Unicode=False
LONGVARCHAR
 
MaxLength= (1<=n<=8000)
Fixed Length=False
Unicode=True
NVARCHAR
 
MaxLength= (1<=n<=8000)
Fixed Length=False
Unicode=False
VARCHAR
 
MaxLength= (1<=n<=8000)
Fixed Length=True
Unicode=True
NCHAR
 
MaxLength= (1<=n<=8000)
Fixed Length=True
Unicode=False
CHAR
TimeSpan
 
TIME
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  
Date and Time Canonical Function
Actian Zen Functions
CLR Type
DateTime.Now
SYSDATETIME()
DateTime
DateTime.Now
SYSDATETIMEOFFSET ()
DateTimeOffset
DateTime.UtcNow
SYSUTCDATETIME()
DateTime
DateTimeOffset
DateTime.Today
CURDATE()
DateTime
DateTimeOffset
AddYears(expression)
DATEADD(year, expression, column)
DateTime
DateTimeOffset
AddMonths(expression)
DATEADD(month, expression, column)
DateTime
DateTimeOffset
AddDays(expression)
DATEADD(day, expression, column)
DateTime
DateTimeOffset
AddHours(expression)
DATEADD(hour, expression, column)
DateTime
DateTimeOffset
AddMinutes(expression)
DATEADD(minute, expression, column)
DateTime
DateTimeOffset
AddSeconds(expression)
DATEADD(second, expression, column)
DateTime
DateTimeOffset
AddMilliSeconds(expression)
DATEADD(millisecond, expression, column)
DateTime
DateTimeOffset
EF.Functions.DateDiffYear(column, expression)
DATEDIFF(year, column, expression)
DateTime
DateTimeOffset
EF.Functions.DateDiffMonth(column, expression)
DATEDIFF(month, column, expression)
DateTime
DateTimeOffset
EF.Functions.DateDiffDay(column, expression)
DATEDIFF(day, column, expression)
DateTime
DateTimeOffset
EF.Functions.DateDiffHour(column, expression)
DATEDIFF(hour, column, expression)
DateTime
DateTimeOffset
TimeSpan
EF.Functions.DateDiffMinute(column, expression)
DATEDIFF(minute, column, expression)
DateTime
DateTimeOffset
TimeSpan
EF.Functions.DateDiffSecond(column, expression)
DATEDIFF(second, column, expression)
DateTime
DateTimeOffset
TimeSpan
EF.Functions.DateDiffMilliSecond(column, expression)
DATEDIFF(millisecond, column, expression)
DateTime
DateTimeOffset
TimeSpan
String 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:
https://docs.microsoft.com/en-in/ef/core/managing-schemas/migrations/history-table
https://docs.microsoft.com/en-in/ef/core/modeling/dynamic-model
Using Stored Procedures with the ADO.NET Entity Framework Core
In Entity Framework Core, stored procedures can be executed using raw SQL queries. For more information, see https://docs.microsoft.com/en-in/ef/core/querying/raw-sql.
Upgrading an Application from Entity Framework 6.x to Entity Framework Core
To upgrade your application from Entity Framework 6.x to Entity Framework Core, see https://docs.microsoft.com/en-us/ef/efcore-and-ef6/porting/.
Limitations
The Actian Zen ADO.NET Entity Framework Core data provider has the following limitations:
The Entity Framework Core has some limitations related to the reverse engineering (scaffolding) feature. They all apply to the Actian Zen Entity Framework Core data provider as well. For more information on these limitations, see https://docs.microsoft.com/en-in/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli.
The Actian Zen Entity Framework Core data provider does not support the concurrency feature of reverse engineering (scaffolding).
For More Information
Refer to the following sources for additional information about the ADO.NET and the Entity Framework Core.
ADO.NET Entity Framework Core introduces the Entity Framework Core and provides links to numerous detailed articles.
Feature Comparison compares the features available in Entity Framework Core and Entity Framework 6.X.
ASP.NET Core shows how to use Entity Framework Core in an ASP.NET Core Razor Pages app.