Developer Reference > Data Access Methods > Data Provider for .NET > Zen ADO.NET Entity Framework Core Data Providers
Zen ADO.NET Entity Framework Core Data Providers
Zen 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.
Zen ADO.NET Entity Framework Core data providers can be used with applications that use the ADO.NET Entity Framework Core. They support the following:
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/.
Zen ADO.NET Entity Framework Core data providers use ADO.NET data providers to communicate with ADO.NET database servers. This means that the functionality defined by Zen ADO.NET data providers applies to Zen ADO.NET Entity Framework Core data providers unless otherwise noted here. Similarly, any performance configurations made to Zen ADO.NET data providers are realized by the Zen ADO.NET Entity Framework Core data providers.
Note: Visual Studio 2019 or later is required when developing applications for the Zen ADO.NET Entity Framework Core.
About Zen ADO.NET Entity Framework Core Data Providers
Zen ADO.NET Entity Framework Core data providers are built with 100% managed code, so they 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 Zen 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 Zen ADO.NET Data Providers Available with SDK Download. Then add the package to your project.
Configuring the Zen 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 Zen 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 Zen ADO.NET Entity Framework Core data provider are the same as those used by the Zen ADO.NET data provider (see the following table for more information). Table lists the connection string options that have a different default value when used with 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
The following table 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.
CLR Type
Property Values That Affect
Type Mapping
Actian Zen Data Type
Bool
 
BIT
Byte
 
UTINYINT
Byte[ ]
 
BINARY
 
LONGVARBINARY1
DateTime
 
AUTOTIMESTAMP
 
DATE
 
TIMESTAMP
 
TIMESTAMP22
DateTimeOffset
 
DATETIME
Decimal
 
CURRENCY
 
DECIMAL2
 
NUMERIC
 
NUMERICSA
 
NUMERICSTS
 
UBIGINT
Double
 
BFLOAT8
 
DOUBLE2
Float
 
FLOAT2
 
REAL
 
BFLOAT4
Guid
 
UNIQUEIDENTIFIER
Int
 
INTEGER2
 
IDENTITY
 
USMALLINT
Long
 
BIGINT2
 
BIGIDENTITY
 
UINTEGER
SByte
 
TINYINT
Short
 
SMALLINT2
 
SMALLIDENTITY
String
 
NLONGVARCHAR2
 
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
The following table describes the mapping of EDM aggregate canonical functions to Zen functions, and also the CLR types to which these functions apply.
Aggregate Canonical Function
Actian Zen functions
CLR Type
BigCount(expression)
COUNT_BIG(expression)
Long
Count(expression)
COUNT(expression)
Int
Math Canonical Functions
The following table describes the mapping of EDM math canonical functions to Zen functions, and also the CLR types to which these functions apply.
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
The following table 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.
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
The following table describes the mapping of EDM string canonical functions to Zen functions, and also the CLR types to which these functions apply.
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
The following table describes the mapping of other canonical functions to Zen functions, and also the CLR types to which these functions apply.
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:
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 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.
Last modified date: 10/31/2023